﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Text;
using netDxf;
using netDxf.Blocks;
using netDxf.Collections;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Objects;
using netDxf.Tables;
using netDxf.Units;
using Attribute = netDxf.Entities.Attribute;
using Image = netDxf.Entities.Image;
using Point = netDxf.Entities.Point;
using Trace = netDxf.Entities.Trace;
using System.Threading;

namespace TestDxfDocument
{
    class drills
    {
        public static void TwistDrill(Dictionary<string, Object> data)  //麻花钻
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            //作图
            //参数
            double soal = 100;
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double sig = Convert.ToDouble(data["sig"]) * pi / 180;
            double pl = Convert.ToDouble(data["pl"]) * scale;
            if (pl == 0)
            {
                pl = dc / 2 / Math.Tan(sig / 2);
            }
            double isframe = Convert.ToDouble(data["isframe"]) * scale;
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            Vector2 v2 = new Vector2(dconms / 2, -0.5);
            Vector2 v1 = new Vector2(v2.X - 0.5, 0);
            Vector2 v3 = new Vector2(v2.X, -ls);
            Vector2 v4 = new Vector2(dc / 2, v3.Y - (dconms - dc) / 2);
            Vector2 v5 = new Vector2(v4.X, -oal + pl);
            Vector2 v6 = new Vector2(pl * Math.Tan(sig / 2), v5.Y);
            Vector2 v7 = new Vector2(0, -oal);
            Vector2 v8 = new Vector2(-v6.X, v6.Y);
            Vector2 v9 = new Vector2(-v5.X, v5.Y);
            Vector2 v10 = new Vector2(-v4.X, v4.Y);
            Vector2 v11 = new Vector2(-v3.X, v3.Y);
            Vector2 v12 = new Vector2(-v2.X, v2.Y);
            Vector2 v13 = new Vector2(-v1.X, v1.Y);
            Vector2 v14 = new Vector2(0, 2);
            Vector2 v15 = new Vector2(0, -oal - 2);
            Vector2 v16 = new Vector2(v8.X, 2 * v7.Y - v8.Y);
            Vector2 v17 = new Vector2(v6.X, 2 * v7.Y - v6.Y);
            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            LwPolyline Arc1 = new LwPolyline();
            Arc1.Vertexes.Add(new LwPolylineVertex(v3));
            Arc1.Vertexes.Add(new LwPolylineVertex(v4));
            Arc1.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
            fun.PolyFill(dxf, Arc1, 0.3, contour);
            LwPolyline Arc2 = new LwPolyline();
            Arc2.Vertexes.Add(new LwPolylineVertex(v10));
            Arc2.Vertexes.Add(new LwPolylineVertex(v11));
            Arc2.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
            fun.PolyFill(dxf, Arc2, 0.3, contour);
            Vector2[] Line3 = { v4, v5 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v5, v6 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v6, v7 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v7, v8 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v8, v9 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v9, v10 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v11, v12 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v12, v13 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v13, v1 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v2, v12 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v3, v11 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v4, v10 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v6, v8 };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v14, v15 };
            fun.drawPlinetype(dxf, Line16, 0.15, centre, Linetype.Center);
            Line Line17 = new Line(v7, v16);
            Line Line18 = new Line(v7, v17);
            //主视图图层
            Line17.Layer = dimensioning;
            Line18.Layer = dimensioning;
            //主视图
            dxf.AddEntity(Line17);
            dxf.AddEntity(Line18);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 2.5;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            Angular2LineDimension angdim1 = new Angular2LineDimension(new Line(v7, v16), new Line(v7, v17), offset / 4, dimensionStyle);
            angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
            dxf.AddEntity(angdim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v9, v5), -pl - offset - 20, 0, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            LinearDimension dim3 = new LinearDimension(new Line(v7, v5), offset + v2.X - v5.X / 2, 270, dimensionStyle);
            dim3.UserText = "PL = " + Math.Round(pl / scale, 2);
            dxf.AddEntity(dim3);
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25, 270, dimensionStyle);
            dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v7, v1), offset * 2 + v1.X / 2, 270, dimensionStyle);
            dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v12, v2), offset + 0.5, 0, dimensionStyle);
            dim6.UserText = "DCONMS = " + Math.Round(dconms / scale, 2);
            dxf.AddEntity(dim6);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(v7.X - 148.5, v7.Y + 210 + oal / 2), data);
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void StepDrill(Dictionary<string, Object> data)  //阶梯钻
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double dc1 = Convert.ToDouble(data["dc1"]) * scale;
            double dc2 = Convert.ToDouble(data["dc2"]) * scale;
            double dc3 = Convert.ToDouble(data["dc3"]) * scale;
            double sdl1 = Convert.ToDouble(data["sdl1"]) * scale;
            double sd3 = Convert.ToDouble(data["sd3"]) * scale;
            double sta2 = Convert.ToDouble(data["sta2"]) * pi / 180;
            double sta3 = Convert.ToDouble(data["sta3"]) * pi / 180;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dmm = Convert.ToDouble(data["dmm"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double sig = Convert.ToDouble(data["sig"]) * pi / 180;
            double pl = Convert.ToDouble(data["pl"]) * scale;
            if (pl == 0)
            {
                pl = dc1 / 2 / Math.Tan(sig / 2);
            }
            string ccms = Convert.ToString(data["ccms"]);
            double czc = Convert.ToDouble(data["czc"]);
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            double db = Convert.ToDouble(data["db"]) * scale;
            double ds = Convert.ToDouble(data["ds"]) * scale;
            double tg = Convert.ToDouble(data["tg"]);
            if (ccms == "MKG")
            {
                if (czc == 0)
                {
                    db = 9.045 * scale;
                    ds = 6.4 * scale;
                    tg = 0.05205;
                }
                if (czc == 1)
                {
                    db = 12.065 * scale;
                    ds = 9.4 * scale;
                    tg = 0.04988;
                }
                if (czc == 2)
                {
                    db = 17.78 * scale;
                    ds = 14.6 * scale;
                    tg = 0.04995;
                }
                if (czc == 3)
                {
                    db = 23.825 * scale;
                    ds = 19.8 * scale;
                    tg = 0.05020;
                }
                if (czc == 4)
                {
                    db = 31.267 * scale;
                    ds = 25.9 * scale;
                    tg = 0.05194;
                }
                if (czc == 5)
                {
                    db = 44.399 * scale;
                    ds = 37.6 * scale;
                    tg = 0.05263;
                }
                if (czc == 6)
                {
                    db = 63.348 * scale;
                    ds = 53.9 * scale;
                    tg = 0.05214;
                }
            }
            if (ccms == "MEG")
            {
                tg = 0.05;
                if (czc == 4)
                {
                    db = 4 * scale;
                    ds = 2.9 * scale;
                }
                if (czc == 6)
                {
                    db = 6 * scale;
                    ds = 4.4 * scale;
                }
                if (czc == 80)
                {
                    db = 80 * scale;
                    ds = 70.2 * scale;
                }
                if (czc == 100)
                {
                    db = 100 * scale;
                    ds = 88.4 * scale;
                }
                if (czc == 120)
                {
                    db = 120 * scale;
                    ds = 106.6 * scale;
                }
                if (czc == 160)
                {
                    db = 160 * scale;
                    ds = 143 * scale;
                }
                if (czc == 200)
                {
                    db = 200 * scale;
                    ds = 179.4 * scale;
                }
            }
            //主视图
            if (ccms == "ZYL" && dc3 != 0)
            {
                //坐标
                Vector2 v1 = new Vector2(dmm / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(dmm / 2, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dc3 / 2, v3.Y - (dmm - dc3) / 2);
                Vector2 v5 = new Vector2(v4.X, -oal + sd3);
                Vector2 v6 = new Vector2(dc2 / 2, v5.Y - (v5.X - dc2 / 2) / Math.Tan(sta3 / 2));
                Vector2 v8 = new Vector2(dc1 / 2, -oal + pl + sdl1);
                Vector2 v7 = new Vector2(v6.X, v8.Y + (v6.X - v8.X) / (Math.Tan(sta2 / 2)));
                Vector2 v9 = new Vector2(v8.X, -oal + pl);
                Vector2 v11 = new Vector2(0, -oal);
                Vector2 v10 = new Vector2(pl * Math.Tan(sig / 2), v9.Y);
                Vector2 v12 = new Vector2(-v10.X, v10.Y);
                Vector2 v13 = new Vector2(-v9.X, v9.Y);
                Vector2 v14 = new Vector2(-v8.X, v8.Y);
                Vector2 v15 = new Vector2(-v7.X, v7.Y);
                Vector2 v16 = new Vector2(-v6.X, v6.Y);
                Vector2 v17 = new Vector2(-v5.X, v5.Y);
                Vector2 v18 = new Vector2(-v4.X, v4.Y);
                Vector2 v19 = new Vector2(-v3.X, v3.Y);
                Vector2 v20 = new Vector2(-v2.X, v2.Y);
                Vector2 v21 = new Vector2(-v1.X, v1.Y);
                Vector2 v22 = new Vector2(0, 2);
                Vector2 v23 = new Vector2(0, -oal - 2);
                Vector2 v24 = new Vector2(v12.X, 2 * v11.Y - v12.Y);
                Vector2 v25 = new Vector2(v10.X, 2 * v11.Y - v10.Y);
                //线段
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                LwPolyline Arc1 = new LwPolyline();
                Arc1.Vertexes.Add(new LwPolylineVertex(v3));
                Arc1.Vertexes.Add(new LwPolylineVertex(v4));
                Arc1.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc1, 0.3, contour);
                LwPolyline Arc2 = new LwPolyline();
                Arc2.Vertexes.Add(new LwPolylineVertex(v18));
                Arc2.Vertexes.Add(new LwPolylineVertex(v19));
                Arc2.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc2, 0.3, contour);
                Vector2[] Line3 = { v4, v5 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v5, v6 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v6, v7 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v7, v8 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v8, v9 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v9, v10 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v10, v11 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v11, v12 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v12, v13 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v13, v14 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v14, v15 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v15, v16 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v16, v17 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v17, v18 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v19, v20 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v20, v21 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v21, v1 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                Vector2[] Line20 = { v20, v2 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v19, v3 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v18, v4 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v17, v5 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v16, v6 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Vector2[] Line25 = { v15, v7 };
                fun.drawBLine(dxf, Line25, 0.3, contour);
                Vector2[] Line26 = { v14, v8 };
                fun.drawBLine(dxf, Line26, 0.3, contour);
                Vector2[] Line27 = { v12, v10 };
                fun.drawBLine(dxf, Line27, 0.3, contour);
                Vector2[] Line28 = { v22, v23 };
                fun.drawPlinetype(dxf, Line28, 0.15, center, Linetype.Center);
                Line Line29 = new Line(v11, v24);
                Line Line30 = new Line(v11, v25);
                //主视图图层
                Line29.Layer = dimensioning;
                Line30.Layer = dimensioning;
                //主视图
                dxf.AddEntity(Line29);
                dxf.AddEntity(Line30);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 2.5;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                Angular2LineDimension angdim1 = new Angular2LineDimension(new Line(v11, v24), new Line(v11, v25), offset / 2, dimensionStyle);
                angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v13, v9), -pl - offset - 10, 0, dimensionStyle);
                dim2.UserText = "DC_1 = " + Math.Round(dc1 / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v15, v7), -v7.Y + v11.Y - offset * 2-20, 0, dimensionStyle);
                dim3.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v17, v5), -sd3 - offset * 3-30, 0, dimensionStyle);
                dim4.UserText = "DC_3 = " + Math.Round(dc3 / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v11, v9), offset / 2 + v2.X - v9.X / 2, 270, dimensionStyle);
                dim5.UserText = "PL = " + Math.Round(pl / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v1, v3), offset + 0.25, 270, dimensionStyle);
                dim6.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v8, v9), offset + v2.X - v8.X, 270, dimensionStyle);
                dim7.UserText = "SDL_1 = " + Math.Round(sdl1 / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v5, v11), offset * 2 + v2.X - v5.X / 2, 270, dimensionStyle);
                dim8.UserText = "SD_3 = " + Math.Round(sd3 / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v11, v1), offset * 3 + v1.X / 2 + 0.25, 270, dimensionStyle);
                dim9.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(v20, v2), offset + 0.5, 0, dimensionStyle);
                dim10.UserText = "DMM = " + Math.Round(dmm / scale, 2);
                dxf.AddEntity(dim10);
                //尺寸11
                Angular2LineDimension angdim11 = new Angular2LineDimension(new Line(v14, v15), new Line(v8, v7), offset / 2, dimensionStyle);
                angdim11.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim11);
                //尺寸12
                Angular2LineDimension angdim12 = new Angular2LineDimension(new Line(v16, v17), new Line(v6, v5), offset / 2, dimensionStyle);
                angdim12.UserText = "STA_3 = " + Math.Round(sta3 / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim12);
            }
            if (ccms == "ZYL" && dc3 == 0)
            {
                Vector2 v1 = new Vector2(dmm / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(dmm / 2, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dc2 / 2, v3.Y - (dmm - dc2) / 2);
                Vector2 v6 = new Vector2(dc1 / 2, -oal + pl + sdl1);
                Vector2 v5 = new Vector2(v4.X, v6.Y + (v4.X - v6.X) / (Math.Tan(sta2 / 2)));
                Vector2 v7 = new Vector2(v6.X, -oal + pl);
                Vector2 v9 = new Vector2(0, -oal);
                Vector2 v8 = new Vector2(pl * Math.Tan(sig / 2), v7.Y);
                Vector2 v10 = new Vector2(-v8.X, v8.Y);
                Vector2 v11 = new Vector2(-v7.X, v7.Y);
                Vector2 v12 = new Vector2(-v6.X, v6.Y);
                Vector2 v13 = new Vector2(-v5.X, v5.Y);
                Vector2 v14 = new Vector2(-v4.X, v4.Y);
                Vector2 v15 = new Vector2(-v3.X, v3.Y);
                Vector2 v16 = new Vector2(-v2.X, v2.Y);
                Vector2 v17 = new Vector2(-v1.X, v1.Y);
                Vector2 v18 = new Vector2(0, 2);
                Vector2 v19 = new Vector2(0, -oal - 2);
                Vector2 v20 = new Vector2(v10.X, 2 * v9.Y - v10.Y);
                Vector2 v21 = new Vector2(v8.X, 2 * v9.Y - v8.Y);
                //线段
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                LwPolyline Arc1 = new LwPolyline();
                Arc1.Vertexes.Add(new LwPolylineVertex(v3));
                Arc1.Vertexes.Add(new LwPolylineVertex(v4));
                Arc1.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc1, 0.3, contour);
                LwPolyline Arc2 = new LwPolyline();
                Arc2.Vertexes.Add(new LwPolylineVertex(v14));
                Arc2.Vertexes.Add(new LwPolylineVertex(v15));
                Arc2.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc2, 0.3, contour);
                Vector2[] Line3 = { v4, v5 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v5, v6 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v6, v7 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v7, v8 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v8, v9 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v9, v10 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v10, v11 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v11, v12 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v12, v13 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v13, v14 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v15, v16 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v16, v17 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v17, v1 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v16, v2 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v15, v3 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v14, v4 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v13, v5 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                Vector2[] Line20 = { v12, v6 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v10, v8 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v18, v19 };
                fun.drawPlinetype(dxf, Line22, 0.15, center, Linetype.Center);
                Line Line23 = new Line(v9, v20);
                Line Line24 = new Line(v9, v21);
                //主视图图层
                Line23.Layer = dimensioning;
                Line24.Layer = dimensioning;
                //主视图
                dxf.AddEntity(Line23);
                dxf.AddEntity(Line24);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                Angular2LineDimension angdim1 = new Angular2LineDimension(new Line(v9, v20), new Line(v9, v21), offset / 2, dimensionStyle);
                angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v11, v7), -pl - offset - 5, 0, dimensionStyle);
                dim2.UserText = "DC_1 = " + Math.Round(dc1 / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v13, v5), -v5.Y + v9.Y - offset * 2, 0, dimensionStyle);
                dim3.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v9, v7), offset + v2.X - v7.X / 2, 270, dimensionStyle);
                dim4.UserText = "PL = " + Math.Round(pl / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v1, v3), offset + 0.25, 270, dimensionStyle);
                dim5.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v6, v7), offset * 2 + v2.X - v6.X, 270, dimensionStyle);
                dim6.UserText = "SDL_1 = " + Math.Round(sdl1 / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v9, v1), offset * 3 + v1.X / 2 + 0.25, 270, dimensionStyle);
                dim7.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v16, v2), offset + 0.5, 0, dimensionStyle);
                dim8.UserText = "DMM = " + Math.Round(dmm / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                Angular2LineDimension angdim9 = new Angular2LineDimension(new Line(v12, v13), new Line(v6, v5), offset / 2, dimensionStyle);
                angdim9.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim9);
            }
            if (ccms == "MKG" || ccms == "MEG")
            {
                if (dc3 != 0)
                {
                    ls = (db - ds) / tg;
                    //坐标
                    Vector2 v1 = new Vector2(ds / 2 - 0.5, 0);
                    Vector2 v2 = new Vector2(ds / 2 + Math.Sqrt(0.25 / (1 + tg * tg / 4)) * tg / 2, -Math.Sqrt(0.25 / (1 + tg * tg / 4)));
                    Vector2 v3 = new Vector2(db / 2, -ls);
                    Vector2 v4 = new Vector2(dc3 / 2, v3.Y - (db - dc3) / 2);
                    Vector2 v5 = new Vector2(v4.X, -oal + sd3);
                    Vector2 v6 = new Vector2(dc2 / 2, v5.Y - (v5.X - dc2 / 2) / Math.Tan(sta3 / 2));
                    Vector2 v8 = new Vector2(dc1 / 2, -oal + pl + sdl1);
                    Vector2 v7 = new Vector2(v6.X, v8.Y + (v6.X - v8.X) / (Math.Tan(sta2 / 2)));
                    Vector2 v9 = new Vector2(v8.X, -oal + pl);
                    Vector2 v11 = new Vector2(0, -oal);
                    Vector2 v10 = new Vector2(pl * Math.Tan(sig / 2), v9.Y);
                    Vector2 v12 = new Vector2(-v10.X, v10.Y);
                    Vector2 v13 = new Vector2(-v9.X, v9.Y);
                    Vector2 v14 = new Vector2(-v8.X, v8.Y);
                    Vector2 v15 = new Vector2(-v7.X, v7.Y);
                    Vector2 v16 = new Vector2(-v6.X, v6.Y);
                    Vector2 v17 = new Vector2(-v5.X, v5.Y);
                    Vector2 v18 = new Vector2(-v4.X, v4.Y);
                    Vector2 v19 = new Vector2(-v3.X, v3.Y);
                    Vector2 v20 = new Vector2(-v2.X, v2.Y);
                    Vector2 v21 = new Vector2(-v1.X, v1.Y);
                    Vector2 v22 = new Vector2(0, 2);
                    Vector2 v23 = new Vector2(0, -oal - 2);
                    Vector2 v24 = new Vector2(v12.X, 2 * v11.Y - v12.Y);
                    Vector2 v25 = new Vector2(v10.X, 2 * v11.Y - v10.Y);
                    //线段
                    Vector2[] Line1 = { v1, v2 };
                    fun.drawBLine(dxf, Line1, 0.3, contour);
                    Vector2[] Line2 = { v2, v3 };
                    fun.drawBLine(dxf, Line2, 0.3, contour);
                    LwPolyline Arc1 = new LwPolyline();
                    Arc1.Vertexes.Add(new LwPolylineVertex(v3));
                    Arc1.Vertexes.Add(new LwPolylineVertex(v4));
                    Arc1.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                    fun.PolyFill(dxf, Arc1, 0.3, contour);
                    LwPolyline Arc2 = new LwPolyline();
                    Arc2.Vertexes.Add(new LwPolylineVertex(v18));
                    Arc2.Vertexes.Add(new LwPolylineVertex(v19));
                    Arc2.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                    fun.PolyFill(dxf, Arc2, 0.3, contour);
                    Vector2[] Line3 = { v4, v5 };
                    fun.drawBLine(dxf, Line3, 0.3, contour);
                    Vector2[] Line4 = { v5, v6 };
                    fun.drawBLine(dxf, Line4, 0.3, contour);
                    Vector2[] Line5 = { v6, v7 };
                    fun.drawBLine(dxf, Line5, 0.3, contour);
                    Vector2[] Line6 = { v7, v8 };
                    fun.drawBLine(dxf, Line6, 0.3, contour);
                    Vector2[] Line7 = { v8, v9 };
                    fun.drawBLine(dxf, Line7, 0.3, contour);
                    Vector2[] Line8 = { v9, v10 };
                    fun.drawBLine(dxf, Line8, 0.3, contour);
                    Vector2[] Line9 = { v10, v11 };
                    fun.drawBLine(dxf, Line9, 0.3, contour);
                    Vector2[] Line10 = { v11, v12 };
                    fun.drawBLine(dxf, Line10, 0.3, contour);
                    Vector2[] Line11 = { v12, v13 };
                    fun.drawBLine(dxf, Line11, 0.3, contour);
                    Vector2[] Line12 = { v13, v14 };
                    fun.drawBLine(dxf, Line12, 0.3, contour);
                    Vector2[] Line13 = { v14, v15 };
                    fun.drawBLine(dxf, Line13, 0.3, contour);
                    Vector2[] Line14 = { v15, v16 };
                    fun.drawBLine(dxf, Line14, 0.3, contour);
                    Vector2[] Line15 = { v16, v17 };
                    fun.drawBLine(dxf, Line15, 0.3, contour);
                    Vector2[] Line16 = { v17, v18 };
                    fun.drawBLine(dxf, Line16, 0.3, contour);
                    Vector2[] Line17 = { v19, v20 };
                    fun.drawBLine(dxf, Line17, 0.3, contour);
                    Vector2[] Line18 = { v20, v21 };
                    fun.drawBLine(dxf, Line18, 0.3, contour);
                    Vector2[] Line19 = { v21, v1 };
                    fun.drawBLine(dxf, Line19, 0.3, contour);
                    Vector2[] Line20 = { v20, v2 };
                    fun.drawBLine(dxf, Line20, 0.3, contour);
                    Vector2[] Line21 = { v19, v3 };
                    fun.drawBLine(dxf, Line21, 0.3, contour);
                    Vector2[] Line22 = { v18, v4 };
                    fun.drawBLine(dxf, Line22, 0.3, contour);
                    Vector2[] Line23 = { v17, v5 };
                    fun.drawBLine(dxf, Line23, 0.3, contour);
                    Vector2[] Line24 = { v16, v6 };
                    fun.drawBLine(dxf, Line24, 0.3, contour);
                    Vector2[] Line25 = { v15, v7 };
                    fun.drawBLine(dxf, Line25, 0.3, contour);
                    Vector2[] Line26 = { v14, v8 };
                    fun.drawBLine(dxf, Line26, 0.3, contour);
                    Vector2[] Line27 = { v12, v10 };
                    fun.drawBLine(dxf, Line27, 0.3, contour);
                    Vector2[] Line28 = { v22, v23 };
                    fun.drawPlinetype(dxf, Line28, 0.15, center, Linetype.Center);
                    Line Line29 = new Line(v11, v24);
                    Line Line30 = new Line(v11, v25);
                    //主视图图层
                    Line29.Layer = dimensioning;
                    Line30.Layer = dimensioning;
                    //主视图
                    dxf.AddEntity(Line29);
                    dxf.AddEntity(Line30);
                    //标注样式
                    //箭头样式
                    DimensionStyle dimensionStyle = fun.CreateDimStyle();
                    dimensionStyle.ArrowSize = 0.2;
                    dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                    dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                    //文本样式
                    dimensionStyle.TextHeight = 1.0;
                    double offset = 10;
                    //线段尺寸标注
                    //尺寸1
                    Angular2LineDimension angdim1 = new Angular2LineDimension(new Line(v11, v24), new Line(v11, v25), offset / 2, dimensionStyle);
                    angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim1);
                    //尺寸2
                    LinearDimension dim2 = new LinearDimension(new Line(v13, v9), -pl - offset - 5, 0, dimensionStyle);
                    dim2.UserText = "DC_1 = " + Math.Round(dc1 / scale, 2);
                    dxf.AddEntity(dim2);
                    //尺寸3
                    LinearDimension dim3 = new LinearDimension(new Line(v15, v7), -v7.Y + v11.Y - offset * 2, 0, dimensionStyle);
                    dim3.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                    dxf.AddEntity(dim3);
                    //尺寸4
                    LinearDimension dim4 = new LinearDimension(new Line(v17, v5), -sd3 - offset * 3, 0, dimensionStyle);
                    dim4.UserText = "DC_3 = " + Math.Round(dc3 / scale, 2);
                    dxf.AddEntity(dim4);
                    //尺寸5
                    LinearDimension dim5 = new LinearDimension(new Line(v11, v9), offset / 2 + v2.X - v9.X / 2, 270, dimensionStyle);
                    dim5.UserText = "PL = " + Math.Round(pl / scale, 2);
                    dxf.AddEntity(dim5);
                    //尺寸7
                    LinearDimension dim7 = new LinearDimension(new Line(v8, v9), offset + v2.X - v8.X, 270, dimensionStyle);
                    dim7.UserText = "SDL_1 = " + Math.Round(sdl1 / scale, 2);
                    dxf.AddEntity(dim7);
                    //尺寸8
                    LinearDimension dim8 = new LinearDimension(new Line(v5, v11), offset * 2 + v2.X - v5.X / 2, 270, dimensionStyle);
                    dim8.UserText = "SD_3 = " + Math.Round(sd3 / scale, 2);
                    dxf.AddEntity(dim8);
                    //尺寸9
                    LinearDimension dim9 = new LinearDimension(new Line(v11, v1), offset * 3 + v1.X / 2 + 0.25, 270, dimensionStyle);
                    dim9.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim9);
                    //尺寸11
                    Angular2LineDimension angdim11 = new Angular2LineDimension(new Line(v14, v15), new Line(v8, v7), offset / 2, dimensionStyle);
                    angdim11.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim11);
                    //尺寸12
                    Angular2LineDimension angdim12 = new Angular2LineDimension(new Line(v16, v17), new Line(v6, v5), offset / 2, dimensionStyle);
                    angdim12.UserText = "STA_3 = " + Math.Round(sta3 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim12);
                }
                if (dc3 == 0)
                {
                    ls = (db - ds) / tg;
                    //坐标
                    Vector2 v1 = new Vector2(ds / 2 - 0.5, 0);
                    Vector2 v2 = new Vector2(ds / 2 + Math.Sqrt(0.25 / (1 + tg * tg / 4)) * tg / 2, -Math.Sqrt(0.25 / (1 + tg * tg / 4)));
                    Vector2 v3 = new Vector2(db / 2, -ls);
                    Vector2 v4 = new Vector2(dc2 / 2, v3.Y - (db - dc2) / 2);
                    Vector2 v6 = new Vector2(dc1 / 2, -oal + pl + sdl1);
                    Vector2 v5 = new Vector2(v4.X, v6.Y + (v4.X - v6.X) / (Math.Tan(sta2 / 2)));
                    Vector2 v7 = new Vector2(v6.X, -oal + pl);
                    Vector2 v9 = new Vector2(0, -oal);
                    Vector2 v8 = new Vector2(pl * Math.Tan(sig / 2), v7.Y);
                    Vector2 v10 = new Vector2(-v8.X, v8.Y);
                    Vector2 v11 = new Vector2(-v7.X, v7.Y);
                    Vector2 v12 = new Vector2(-v6.X, v6.Y);
                    Vector2 v13 = new Vector2(-v5.X, v5.Y);
                    Vector2 v14 = new Vector2(-v4.X, v4.Y);
                    Vector2 v15 = new Vector2(-v3.X, v3.Y);
                    Vector2 v16 = new Vector2(-v2.X, v2.Y);
                    Vector2 v17 = new Vector2(-v1.X, v1.Y);
                    Vector2 v18 = new Vector2(0, 2);
                    Vector2 v19 = new Vector2(0, -oal - 2);
                    Vector2 v20 = new Vector2(v10.X, 2 * v9.Y - v10.Y);
                    Vector2 v21 = new Vector2(v8.X, 2 * v9.Y - v8.Y);
                    //线段
                    Vector2[] Line1 = { v1, v2 };
                    fun.drawBLine(dxf, Line1, 0.3, contour);
                    Vector2[] Line2 = { v2, v3 };
                    fun.drawBLine(dxf, Line2, 0.3, contour);
                    LwPolyline Arc1 = new LwPolyline();
                    Arc1.Vertexes.Add(new LwPolylineVertex(v3));
                    Arc1.Vertexes.Add(new LwPolylineVertex(v4));
                    Arc1.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                    fun.PolyFill(dxf, Arc1, 0.3, contour);
                    LwPolyline Arc2 = new LwPolyline();
                    Arc2.Vertexes.Add(new LwPolylineVertex(v14));
                    Arc2.Vertexes.Add(new LwPolylineVertex(v15));
                    Arc2.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                    fun.PolyFill(dxf, Arc2, 0.3, contour);
                    Vector2[] Line3 = { v4, v5 };
                    fun.drawBLine(dxf, Line3, 0.3, contour);
                    Vector2[] Line4 = { v5, v6 };
                    fun.drawBLine(dxf, Line4, 0.3, contour);
                    Vector2[] Line5 = { v6, v7 };
                    fun.drawBLine(dxf, Line5, 0.3, contour);
                    Vector2[] Line6 = { v7, v8 };
                    fun.drawBLine(dxf, Line6, 0.3, contour);
                    Vector2[] Line7 = { v8, v9 };
                    fun.drawBLine(dxf, Line7, 0.3, contour);
                    Vector2[] Line8 = { v9, v10 };
                    fun.drawBLine(dxf, Line8, 0.3, contour);
                    Vector2[] Line9 = { v10, v11 };
                    fun.drawBLine(dxf, Line9, 0.3, contour);
                    Vector2[] Line10 = { v11, v12 };
                    fun.drawBLine(dxf, Line10, 0.3, contour);
                    Vector2[] Line11 = { v12, v13 };
                    fun.drawBLine(dxf, Line11, 0.3, contour);
                    Vector2[] Line12 = { v13, v14 };
                    fun.drawBLine(dxf, Line12, 0.3, contour);
                    Vector2[] Line13 = { v15, v16 };
                    fun.drawBLine(dxf, Line13, 0.3, contour);
                    Vector2[] Line14 = { v16, v17 };
                    fun.drawBLine(dxf, Line14, 0.3, contour);
                    Vector2[] Line15 = { v17, v1 };
                    fun.drawBLine(dxf, Line15, 0.3, contour);
                    Vector2[] Line16 = { v16, v2 };
                    fun.drawBLine(dxf, Line16, 0.3, contour);
                    Vector2[] Line17 = { v15, v3 };
                    fun.drawBLine(dxf, Line17, 0.3, contour);
                    Vector2[] Line18 = { v14, v4 };
                    fun.drawBLine(dxf, Line18, 0.3, contour);
                    Vector2[] Line19 = { v13, v5 };
                    fun.drawBLine(dxf, Line19, 0.3, contour);
                    Vector2[] Line20 = { v12, v6 };
                    fun.drawBLine(dxf, Line20, 0.3, contour);
                    Vector2[] Line21 = { v10, v8 };
                    fun.drawBLine(dxf, Line21, 0.3, contour);
                    Vector2[] Line22 = { v18, v19 };
                    fun.drawPlinetype(dxf, Line22, 0.15, center, Linetype.Center);
                    Line Line23 = new Line(v9, v20);
                    Line Line24 = new Line(v9, v21);
                    //主视图图层
                    Line23.Layer = dimensioning;
                    Line24.Layer = dimensioning;
                    //主视图
                    dxf.AddEntity(Line23);
                    dxf.AddEntity(Line24);
                    //标注样式
                    //箭头样式
                    DimensionStyle dimensionStyle = fun.CreateDimStyle();
                    dimensionStyle.ArrowSize = 0.2;
                    dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                    dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                    //文本样式
                    dimensionStyle.TextHeight = 2.5;
                    double offset = 10;
                    //线段尺寸标注
                    //尺寸1
                    Angular2LineDimension angdim1 = new Angular2LineDimension(new Line(v9, v20), new Line(v9, v21), offset / 2, dimensionStyle);
                    angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim1);
                    //尺寸2
                    LinearDimension dim2 = new LinearDimension(new Line(v11, v7), -pl - offset - 5, 0, dimensionStyle);
                    dim2.UserText = "DC_1 = " + Math.Round(dc1 / scale, 2);
                    dxf.AddEntity(dim2);
                    //尺寸3
                    LinearDimension dim3 = new LinearDimension(new Line(v13, v5), -v5.Y + v9.Y - offset * 2, 0, dimensionStyle);
                    dim3.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                    dxf.AddEntity(dim3);
                    //尺寸4
                    LinearDimension dim4 = new LinearDimension(new Line(v9, v7), offset + v2.X - v7.X / 2, 270, dimensionStyle);
                    dim4.UserText = "PL = " + Math.Round(pl / scale, 2);
                    dxf.AddEntity(dim4);
                    //尺寸6
                    LinearDimension dim6 = new LinearDimension(new Line(v6, v7), offset * 2 + v2.X - v6.X, 270, dimensionStyle);
                    dim6.UserText = "SDL_1 = " + Math.Round(sdl1 / scale, 2);
                    dxf.AddEntity(dim6);
                    //尺寸7
                    LinearDimension dim7 = new LinearDimension(new Line(v9, v1), offset * 3 + v1.X / 2 + 0.25, 270, dimensionStyle);
                    dim7.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim7);
                    //尺寸9
                    Angular2LineDimension angdim9 = new Angular2LineDimension(new Line(v12, v13), new Line(v6, v5), offset / 2, dimensionStyle);
                    angdim9.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim9);
                }
            }
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 200 - oal / 2), data);
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void CoreDrill(Dictionary<string, Object> data)  //扩孔钻
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            //作图
            //参数
            string path = Convert.ToString(data["path"]);
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dmm = Convert.ToDouble(data["dmm"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double sig = Convert.ToDouble(data["sig"]) * pi / 180;
            double dcintf = Convert.ToDouble(data["dcintf"]) * scale;
            if (dcintf == 0)
            {
                dcintf = dc;
            }
            double pl = ((dc - dcintf) / 2) / Math.Tan(sig / 2);
            string ccms = Convert.ToString(data["ccms"]);
            double czc = Convert.ToDouble(data["czc"]);
            double isframe = Convert.ToDouble(data["isframe"]);
            double db = Convert.ToDouble(data["db"]) * scale;
            double ds = Convert.ToDouble(data["ds"]) * scale;
            double tg = Convert.ToDouble(data["tg"]);
            if (ccms == "MKG")
            {
                if (czc == 0)
                {
                    db = 9.045 * scale;
                    ds = 6.4 * scale;
                    tg = 0.05205;
                }
                if (czc == 1)
                {
                    db = 12.065 * scale;
                    ds = 9.4 * scale;
                    tg = 0.04988;
                }
                if (czc == 2)
                {
                    db = 17.78 * scale;
                    ds = 14.6 * scale;
                    tg = 0.04995;
                }
                if (czc == 3)
                {
                    db = 23.825 * scale;
                    ds = 19.8 * scale;
                    tg = 0.05020;
                }
                if (czc == 4)
                {
                    db = 31.267 * scale;
                    ds = 25.9 * scale;
                    tg = 0.05194;
                }
                if (czc == 5)
                {
                    db = 44.399 * scale;
                    ds = 37.6 * scale;
                    tg = 0.05263;
                }
                if (czc == 6)
                {
                    db = 63.348 * scale;
                    ds = 53.9 * scale;
                    tg = 0.05214;
                }
            }
            if (ccms == "MEG")
            {
                tg = 0.05;
                if (czc == 4)
                {
                    db = 4 * scale;
                    ds = 2.9 * scale;
                }
                if (czc == 6)
                {
                    db = 6 * scale;
                    ds = 4.4 * scale;
                }
                if (czc == 80)
                {
                    db = 80 * scale;
                    ds = 70.2 * scale;
                }
                if (czc == 100)
                {
                    db = 100 * scale;
                    ds = 88.4 * scale;
                }
                if (czc == 120)
                {
                    db = 120 * scale;
                    ds = 106.6 * scale;
                }
                if (czc == 160)
                {
                    db = 160 * scale;
                    ds = 143 * scale;
                }
                if (czc == 200)
                {
                    db = 200 * scale;
                    ds = 179.4 * scale;
                }
            }
            //主视图
            if (ccms == "ZYL")
            {
                //坐标
                Vector2 v1 = new Vector2(dmm / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(dmm / 2, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dc / 2, v3.Y - (dmm - dc) / 2);
                Vector2 v5 = new Vector2(v4.X, -oal + pl);
                Vector2 v6 = new Vector2(dcintf / 2, -oal);
                Vector2 v7 = new Vector2(-v6.X, v6.Y);
                Vector2 v8 = new Vector2(-v5.X, v5.Y);
                Vector2 v9 = new Vector2(-v4.X, v4.Y);
                Vector2 v10 = new Vector2(-v3.X, v3.Y);
                Vector2 v11 = new Vector2(-v2.X, v2.Y);
                Vector2 v12 = new Vector2(-v1.X, v1.Y);
                Vector2 v13 = new Vector2(0, 2);
                Vector2 v14 = new Vector2(0, -oal - 2);
                Vector2 v15 = new Vector2(v7.X, v7.Y - dcintf / Math.Tan(sig / 2));
                Vector2 v16 = new Vector2(v6.X, v15.Y);
                //线段
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                LwPolyline Arc1 = new LwPolyline();
                Arc1.Vertexes.Add(new LwPolylineVertex(v3));
                Arc1.Vertexes.Add(new LwPolylineVertex(v4));
                Arc1.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc1, 0.3, contour);
                LwPolyline Arc2 = new LwPolyline();
                Arc2.Vertexes.Add(new LwPolylineVertex(v9));
                Arc2.Vertexes.Add(new LwPolylineVertex(v10));
                Arc2.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc2, 0.3, contour);
                Vector2[] Line3 = { v4, v5 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v5, v6 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v6, v7 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v7, v8 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v8, v9 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v10, v11 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v11, v12 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v12, v1 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v13, v14 };
                fun.drawPlinetype(dxf, Line11, 0.15, centre, Linetype.Center);
                Line Line12 = new Line(v6, v15);
                Line Line13 = new Line(v7, v16);
                Vector2[] Line14 = { v11, v2 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v10, v3 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v9, v4 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v8, v5 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                //主视图图层
                Line12.Layer = dimensioning;
                Line13.Layer = dimensioning;
                //主视图
                if (dcintf != 0 && dcintf - dc != 0)
                {
                    dxf.AddEntity(Line12);
                    dxf.AddEntity(Line13);
                }
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 2.5;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                Angular2LineDimension angdim1 = new Angular2LineDimension(Line12, Line13, offset / 2, dimensionStyle);
                angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
                if (dcintf != 0 && dcintf - dc != 0)
                {
                    dxf.AddEntity(angdim1);
                }
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v7, v6), -offset * 2 - 2.5, 0, dimensionStyle);
                dim2.UserText = "DCINTF = " + Math.Round(dcintf / scale, 2);
                if (dcintf != 0 && dcintf - dc != 0)
                {
                    dxf.AddEntity(dim2);
                }
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v8, v5), -pl - offset * 3, 0, dimensionStyle);
                dim3.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v5, v6), -offset * 2 - 5 - v2.X + (v5.X + v6.X) / 2, 270, dimensionStyle);
                dim4.UserText = "PL = " + Math.Round(pl / scale, 2);
                if (dcintf != 0 && dcintf - dc != 0)
                {
                    dxf.AddEntity(dim4);
                }
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v1, v3), offset + 0.25, 270, dimensionStyle);
                dim5.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v1, v6), offset * 2 + (v2.X - v6.X) / 2 + 0.25, 270, dimensionStyle);
                dim6.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v11, v2), offset + 0.5, 0, dimensionStyle);
                dim7.UserText = "DMM = " + Math.Round(dmm / scale, 2);
                dxf.AddEntity(dim7);
            }
            if (ccms == "MKG" || ccms == "MEG")
            {
                ls = (db - ds) / tg;
                //坐标
                Vector2 v1 = new Vector2(ds / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(ds / 2 + Math.Sqrt(0.25 / (1 + tg * tg / 4)) * tg / 2, -Math.Sqrt(0.25 / (1 + tg * tg / 4)));
                Vector2 v3 = new Vector2(db / 2, -ls);
                Vector2 v4 = new Vector2(dc / 2, v3.Y - (dmm - dc) / 2);
                Vector2 v5 = new Vector2(v4.X, -oal + pl);
                Vector2 v6 = new Vector2(dcintf / 2, -oal);
                Vector2 v7 = new Vector2(-v6.X, v6.Y);
                Vector2 v8 = new Vector2(-v5.X, v5.Y);
                Vector2 v9 = new Vector2(-v4.X, v4.Y);
                Vector2 v10 = new Vector2(-v3.X, v3.Y);
                Vector2 v11 = new Vector2(-v2.X, v2.Y);
                Vector2 v12 = new Vector2(-v1.X, v1.Y);
                Vector2 v13 = new Vector2(0, 2);
                Vector2 v14 = new Vector2(0, -oal - 2);
                Vector2 v15 = new Vector2(v7.X, v7.Y - dcintf / Math.Tan(sig / 2));
                Vector2 v16 = new Vector2(v6.X, v15.Y);
                //线段
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                LwPolyline Arc1 = new LwPolyline();
                Arc1.Vertexes.Add(new LwPolylineVertex(v3));
                Arc1.Vertexes.Add(new LwPolylineVertex(v4));
                Arc1.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc1, 0.3, contour);
                LwPolyline Arc2 = new LwPolyline();
                Arc2.Vertexes.Add(new LwPolylineVertex(v9));
                Arc2.Vertexes.Add(new LwPolylineVertex(v10));
                Arc2.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc2, 0.3, contour);
                Vector2[] Line3 = { v4, v5 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v5, v6 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v6, v7 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v7, v8 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v8, v9 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v10, v11 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v11, v12 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v12, v1 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v13, v14 };
                fun.drawPlinetype(dxf, Line11, 0.15, centre, Linetype.Center);
                Line Line12 = new Line(v6, v15);
                Line Line13 = new Line(v7, v16);
                Vector2[] Line14 = { v11, v2 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v10, v3 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v9, v4 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v8, v5 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                //主视图图层
                Line12.Layer = dimensioning;
                Line13.Layer = dimensioning;
                //主视图
                if (dcintf != 0 && dcintf - dc != 0)
                {
                    dxf.AddEntity(Line12);
                    dxf.AddEntity(Line13);
                }
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 2.5;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                Angular2LineDimension angdim1 = new Angular2LineDimension(Line12, Line13, offset / 2, dimensionStyle);
                angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
                if (dcintf != 0 && dcintf - dc != 0)
                {
                    dxf.AddEntity(angdim1);
                }
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v7, v6), -offset * 2 - 2.5, 0, dimensionStyle);
                dim2.UserText = "DCINTF = " + Math.Round(dcintf / scale, 2);
                if (dcintf != 0 && dcintf - dc != 0)
                {
                    dxf.AddEntity(dim2);
                }
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v8, v5), -pl - offset * 3, 0, dimensionStyle);
                dim3.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v5, v6), -offset * 2 - 5 - v2.X + (v5.X + v6.X) / 2, 270, dimensionStyle);
                dim4.UserText = "PL = " + Math.Round(pl / scale, 2);
                if (dcintf != 0 && dcintf - dc != 0)
                {
                    dxf.AddEntity(dim4);
                }
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v1, v6), offset * 2 + (v2.X - v6.X) / 2 + 0.25, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
            }
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 200 - oal / 2), data);
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void CounterboreDrill(Dictionary<string, Object> data)  //锪钻
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dn = Convert.ToDouble(data["dn"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dmm = Convert.ToDouble(data["dconms"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double sig = 180 * pi / 180;
            double lcf = Convert.ToDouble(data["lcf"]) * scale;
            string ccms = Convert.ToString(data["ccms"]);
            double czc = Convert.ToDouble(data["czc"]);
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            double db = Convert.ToDouble(data["db"]) * scale;
            double ds = Convert.ToDouble(data["ds"]) * scale;
            double tg = Convert.ToDouble(data["tg"]);
            if (ccms == "MKG")
            {
                if (czc == 0)
                {
                    db = 9.045 * scale;
                    ds = 6.4 * scale;
                    tg = 0.05205;
                }
                if (czc == 1)
                {
                    db = 12.065 * scale;
                    ds = 9.4 * scale;
                    tg = 0.04988;
                }
                if (czc == 2)
                {
                    db = 17.78 * scale;
                    ds = 14.6 * scale;
                    tg = 0.04995;
                }
                if (czc == 3)
                {
                    db = 23.825 * scale;
                    ds = 19.8 * scale;
                    tg = 0.05020;
                }
                if (czc == 4)
                {
                    db = 31.267 * scale;
                    ds = 25.9 * scale;
                    tg = 0.05194;
                }
                if (czc == 5)
                {
                    db = 44.399 * scale;
                    ds = 37.6 * scale;
                    tg = 0.05263;
                }
                if (czc == 6)
                {
                    db = 63.348 * scale;
                    ds = 53.9 * scale;
                    tg = 0.05214;
                }
            }
            if (ccms == "MEG")
            {
                tg = 0.05;
                if (czc == 4)
                {
                    db = 4 * scale;
                    ds = 2.9 * scale;
                }
                if (czc == 6)
                {
                    db = 6 * scale;
                    ds = 4.4 * scale;
                }
                if (czc == 80)
                {
                    db = 80 * scale;
                    ds = 70.2 * scale;
                }
                if (czc == 100)
                {
                    db = 100 * scale;
                    ds = 88.4 * scale;
                }
                if (czc == 120)
                {
                    db = 120 * scale;
                    ds = 106.6 * scale;
                }
                if (czc == 160)
                {
                    db = 160 * scale;
                    ds = 143 * scale;
                }
                if (czc == 200)
                {
                    db = 200 * scale;
                    ds = 179.4 * scale;
                }
            }
            //主视图
            if (ccms == "ZYL")
            {
                //坐标
                Vector2 v1 = new Vector2(dmm / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(dmm / 2, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - (dmm - dn) / 2);
                Vector2 v5 = new Vector2(v4.X, -oal + lcf);
                Vector2 v6 = new Vector2(dc / 2, v5.Y - (dc - dn) / 2);
                Vector2 v7 = new Vector2(v6.X, -oal);
                Vector2 v8 = new Vector2(-v7.X, v7.Y);
                Vector2 v9 = new Vector2(-v6.X, v6.Y);
                Vector2 v10 = new Vector2(-v5.X, v5.Y);
                Vector2 v11 = new Vector2(-v4.X, v4.Y);
                Vector2 v12 = new Vector2(-v3.X, v3.Y);
                Vector2 v13 = new Vector2(-v2.X, v2.Y);
                Vector2 v14 = new Vector2(-v1.X, v1.Y);
                Vector2 v15 = new Vector2(0, 2);
                Vector2 v16 = new Vector2(0, -oal - 2);
                Vector2 v17 = new Vector2(v8.X - 2, -oal - 0.01);
                Vector2 v18 = new Vector2(v7.X + 2, -oal - 0.01);
                //线段
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                LwPolyline Arc1 = new LwPolyline();
                Arc1.Vertexes.Add(new LwPolylineVertex(v3));
                Arc1.Vertexes.Add(new LwPolylineVertex(v4));
                Arc1.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc1, 0.3, contour);
                LwPolyline Arc2 = new LwPolyline();
                Arc2.Vertexes.Add(new LwPolylineVertex(v11));
                Arc2.Vertexes.Add(new LwPolylineVertex(v12));
                Arc2.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc2, 0.3, contour);
                Vector2[] Line3 = { v4, v5 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v5, v6 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v6, v7 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v7, v8 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v8, v9 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v9, v10 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v10, v11 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v12, v13 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v13, v14 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v14, v1 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v15, v16 };
                fun.drawPlinetype(dxf, Line13, 0.15, centre, Linetype.Center);
                Line Line14 = new Line(new Vector2(0, -oal), v17);
                Line Line15 = new Line(new Vector2(0, -oal), v18);
                Vector2[] Line16 = { v13, v2 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v12, v3 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v11, v4 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v10, v5 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                Vector2[] Line20 = { v9, v6 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                //主视图图层
                Line14.Layer = dimensioning;
                Line15.Layer = dimensioning;
                //主视图
                dxf.AddEntity(Line14);
                dxf.AddEntity(Line15);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 2.5;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                Angular2LineDimension angdim1 = new Angular2LineDimension(Line14, Line15, offset * 2, dimensionStyle);
                angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v8, v7), -offset, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v1, v3), offset + 0.25, 270, dimensionStyle);
                dim3.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v1, v7), offset * 2 + (v2.X - v7.X) / 2 + 0.25, 270, dimensionStyle);
                dim4.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v13, v2), offset + 0.5, 0, dimensionStyle);
                dim5.UserText = "DMM = " + Math.Round(dmm / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v5, v7), offset + (v7.X - v5.X) / 2, 270, dimensionStyle);
                dim6.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                dxf.AddEntity(dim6);
            }
            if (ccms == "MKG" || ccms == "MEG")
            {
                ls = (db - ds) / tg;
                //坐标
                Vector2 v1 = new Vector2(ds / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(ds / 2 + Math.Sqrt(0.25 / (1 + tg * tg / 4)) * tg / 2, -Math.Sqrt(0.25 / (1 + tg * tg / 4)));
                Vector2 v3 = new Vector2(db / 2, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - (db - dn) / 2);
                Vector2 v5 = new Vector2(v4.X, -oal + lcf);
                Vector2 v6 = new Vector2(dc / 2, v5.Y - (dc - dn) / 2);
                Vector2 v7 = new Vector2(v6.X, -oal);
                Vector2 v8 = new Vector2(-v7.X, v7.Y);
                Vector2 v9 = new Vector2(-v6.X, v6.Y);
                Vector2 v10 = new Vector2(-v5.X, v5.Y);
                Vector2 v11 = new Vector2(-v4.X, v4.Y);
                Vector2 v12 = new Vector2(-v3.X, v3.Y);
                Vector2 v13 = new Vector2(-v2.X, v2.Y);
                Vector2 v14 = new Vector2(-v1.X, v1.Y);
                Vector2 v15 = new Vector2(0, 2);
                Vector2 v16 = new Vector2(0, -oal - 2);
                Vector2 v17 = new Vector2(v8.X - 2, -oal - 0.01);
                Vector2 v18 = new Vector2(v7.X + 2, -oal - 0.01);
                //线段
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                LwPolyline Arc1 = new LwPolyline();
                Arc1.Vertexes.Add(new LwPolylineVertex(v3));
                Arc1.Vertexes.Add(new LwPolylineVertex(v4));
                Arc1.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc1, 0.3, contour);
                LwPolyline Arc2 = new LwPolyline();
                Arc2.Vertexes.Add(new LwPolylineVertex(v11));
                Arc2.Vertexes.Add(new LwPolylineVertex(v12));
                Arc2.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc2, 0.3, contour);
                Vector2[] Line3 = { v4, v5 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v5, v6 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v6, v7 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v7, v8 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v8, v9 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v9, v10 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v10, v11 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v12, v13 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v13, v14 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v14, v1 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v15, v16 };
                fun.drawPlinetype(dxf, Line13, 0.15, centre, Linetype.Center);
                Line Line14 = new Line(new Vector2(0, -oal), v17);
                Line Line15 = new Line(new Vector2(0, -oal), v18);
                Vector2[] Line16 = { v13, v2 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v12, v3 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v11, v4 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v10, v5 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                Vector2[] Line20 = { v9, v6 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                //主视图图层
                Line14.Layer = dimensioning;
                Line15.Layer = dimensioning;
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 2.5;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                Angular2LineDimension angdim1 = new Angular2LineDimension(Line14, Line15, offset * 2, dimensionStyle);
                angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v8, v7), -offset, 0, dimensionStyle);
                dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v1, v7), offset * 2 + (v2.X - v7.X) / 2 + 0.25, 270, dimensionStyle);
                dim4.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v5, v7), offset + (v7.X - v5.X) / 2, 270, dimensionStyle);
                dim6.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                dxf.AddEntity(dim6);
            }
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 200 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void SteppedCountersinkingTool(Dictionary<string, Object> data)  //阶梯锪孔刀具
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double dc1 = Convert.ToDouble(data["dc1"]) * scale;
            double dc2 = Convert.ToDouble(data["dc2"]) * scale;
            double dc3 = Convert.ToDouble(data["dc3"]) * scale;
            double dcintf = Convert.ToDouble(data["dcintf"]) * scale;
            double dn = Convert.ToDouble(data["dn"]) * scale;
            double lcf = Convert.ToDouble(data["lcf"]) * scale;
            double sdl1 = Convert.ToDouble(data["sdl1"]) * scale;
            double sta2 = Convert.ToDouble(data["sta2"]) * pi / 180;
            double sta3 = Convert.ToDouble(data["sta3"]) * pi / 180;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dmm = Convert.ToDouble(data["dmm"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double sig = Convert.ToDouble(data["sig"]) * pi / 180;
            double sd3 = Convert.ToDouble(data["sd3"]) * scale;
            double sd2 = (dc1 - dcintf) / 2 / Math.Tan(sig / 2) + sdl1 + (dc2 - dc1) / 2 / Math.Tan(sta2 / 2);
            double sdl2 = sd3 - sd2 - (dc3 - dc2) / 2 / Math.Tan(sta3 / 2);
            string ccms = Convert.ToString(data["ccms"]);
            double czc = Convert.ToDouble(data["czc"]);
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            double db = Convert.ToDouble(data["db"]) * scale;
            double ds = Convert.ToDouble(data["ds"]) * scale;
            double tg = Convert.ToDouble(data["tg"]);
            if (ccms == "MKG")
            {
                if (czc == 0)
                {
                    db = 9.045 * scale;
                    ds = 6.4 * scale;
                    tg = 0.05205;
                }
                if (czc == 1)
                {
                    db = 12.065 * scale;
                    ds = 9.4 * scale;
                    tg = 0.04988;
                }
                if (czc == 2)
                {
                    db = 17.78 * scale;
                    ds = 14.6 * scale;
                    tg = 0.04995;
                }
                if (czc == 3)
                {
                    db = 23.825 * scale;
                    ds = 19.8 * scale;
                    tg = 0.05020;
                }
                if (czc == 4)
                {
                    db = 31.267 * scale;
                    ds = 25.9 * scale;
                    tg = 0.05194;
                }
                if (czc == 5)
                {
                    db = 44.399 * scale;
                    ds = 37.6 * scale;
                    tg = 0.05263;
                }
                if (czc == 6)
                {
                    db = 63.348 * scale;
                    ds = 53.9 * scale;
                    tg = 0.05214;
                }
            }
            if (ccms == "MEG")
            {
                tg = 0.05;
                if (czc == 4)
                {
                    db = 4 * scale;
                    ds = 2.9 * scale;
                }
                if (czc == 6)
                {
                    db = 6 * scale;
                    ds = 4.4 * scale;
                }
                if (czc == 80)
                {
                    db = 80 * scale;
                    ds = 70.2 * scale;
                }
                if (czc == 100)
                {
                    db = 100 * scale;
                    ds = 88.4 * scale;
                }
                if (czc == 120)
                {
                    db = 120 * scale;
                    ds = 106.6 * scale;
                }
                if (czc == 160)
                {
                    db = 160 * scale;
                    ds = 143 * scale;
                }
                if (czc == 200)
                {
                    db = 200 * scale;
                    ds = 179.4 * scale;
                }
            }
            //主视图
            if (ccms == "ZYL" && dc3 != 0)
            {
                //坐标
                Vector2 v1 = new Vector2(dmm / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(dmm / 2, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - (dmm - dn) / 2);
                Vector2 v5 = new Vector2(v4.X, -oal + lcf);
                Vector2 v6 = new Vector2((dc3 - dn) / 4 + v5.X, v5.Y);
                Vector2 v7 = new Vector2(dc3 / 2, v6.Y - (dc3 / 2 - v6.X));
                Vector2 v8 = new Vector2(v7.X, -oal + sd3);
                Vector2 v9 = new Vector2(dc2 / 2, -oal + sd2 + sdl2);
                Vector2 v10 = new Vector2(v9.X, -oal + sd2);
                Vector2 v12 = new Vector2(dc1 / 2, -oal + (dc1 - dcintf) / 2 / Math.Tan(sig / 2));
                Vector2 v11 = new Vector2(v12.X, v12.Y + sdl1);
                Vector2 v13 = new Vector2(dcintf / 2, -oal);
                Vector2 v14 = new Vector2(-v13.X, v13.Y);
                Vector2 v15 = new Vector2(-v12.X, v12.Y);
                Vector2 v16 = new Vector2(-v11.X, v11.Y);
                Vector2 v17 = new Vector2(-v10.X, v10.Y);
                Vector2 v18 = new Vector2(-v9.X, v9.Y);
                Vector2 v19 = new Vector2(-v8.X, v8.Y);
                Vector2 v20 = new Vector2(-v7.X, v7.Y);
                Vector2 v21 = new Vector2(-v6.X, v6.Y);
                Vector2 v22 = new Vector2(-v5.X, v5.Y);
                Vector2 v23 = new Vector2(-v4.X, v4.Y);
                Vector2 v24 = new Vector2(-v3.X, v3.Y);
                Vector2 v25 = new Vector2(-v2.X, v2.Y);
                Vector2 v26 = new Vector2(-v1.X, v1.Y);
                Vector2 v27 = new Vector2(0, 2);
                Vector2 v28 = new Vector2(0, -oal - 2);
                Vector2 v29 = new Vector2(v14.X, v13.Y - 2 * (v13.X / Math.Tan(sig / 2)));
                Vector2 v30 = new Vector2(-v29.X, v29.Y);
                //线段
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                LwPolyline Arc1 = new LwPolyline();
                Arc1.Vertexes.Add(new LwPolylineVertex(v3));
                Arc1.Vertexes.Add(new LwPolylineVertex(v4));
                Arc1.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc1, 0.3, contour);
                LwPolyline Arc2 = new LwPolyline();
                Arc2.Vertexes.Add(new LwPolylineVertex(v23));
                Arc2.Vertexes.Add(new LwPolylineVertex(v24));
                Arc2.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc2, 0.3, contour);
                Vector2[] Line3 = { v4, v5 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v5, v6 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v6, v7 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v7, v8 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v8, v9 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v9, v10 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v10, v11 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v11, v12 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v12, v13 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v13, v14 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v14, v15 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v15, v16 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v16, v17 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v17, v18 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v18, v19 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v19, v20 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v20, v21 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                Vector2[] Line20 = { v21, v22 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v22, v23 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v24, v25 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v25, v26 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v26, v1 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Vector2[] Line25 = { v25, v2 };
                fun.drawBLine(dxf, Line25, 0.3, contour);
                Vector2[] Line26 = { v24, v3 };
                fun.drawBLine(dxf, Line26, 0.3, contour);
                Vector2[] Line27 = { v23, v4 };
                fun.drawBLine(dxf, Line27, 0.3, contour);
                Vector2[] Line28 = { v22, v5 };
                fun.drawBLine(dxf, Line28, 0.3, contour);
                Vector2[] Line29 = { v20, v7 };
                fun.drawBLine(dxf, Line29, 0.3, contour);
                Vector2[] Line30 = { v19, v8 };
                fun.drawBLine(dxf, Line30, 0.3, contour);
                Vector2[] Line31 = { v18, v9 };
                fun.drawBLine(dxf, Line31, 0.3, contour);
                Vector2[] Line32 = { v17, v10 };
                fun.drawBLine(dxf, Line32, 0.3, contour);
                Vector2[] Line33 = { v16, v11 };
                fun.drawBLine(dxf, Line33, 0.3, contour);
                Vector2[] Line34 = { v15, v12 };
                fun.drawBLine(dxf, Line34, 0.3, contour);
                Vector2[] Line35 = { v27, v28 };
                fun.drawPlinetype(dxf, Line35, 0.15, centre, Linetype.Center);
                Line Line36 = new Line(v13, v29);
                Line Line37 = new Line(v14, v30);
                //主视图图层
                Line36.Layer = dimensioning;
                Line37.Layer = dimensioning;
                //主视图
                dxf.AddEntity(Line36);
                dxf.AddEntity(Line37);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 2.5;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                Angular2LineDimension angdim1 = new Angular2LineDimension(Line36, Line37, offset / 2, dimensionStyle);
                angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v15, v12), -(v12.Y - v13.Y) - offset * 3, 0, dimensionStyle);
                dim2.UserText = "DC_1 = " + Math.Round(dc1 / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v17, v10), -v10.Y + v13.Y - offset * 4, 0, dimensionStyle);
                dim3.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v19, v8), -sd3 - offset * 5, 0, dimensionStyle);
                dim4.UserText = "DC_3 = " + Math.Round(dc3 / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v14, v13), -offset * 2 - 4, 0, dimensionStyle);
                dim5.UserText = "DCINTF = " + Math.Round(dcintf / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v1, v3), offset + 0.25, 270, dimensionStyle);
                dim6.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v11, v12), offset * 3 + v7.X - v11.X, 270, dimensionStyle);
                dim7.UserText = "SDL_1 = " + Math.Round(sdl1 / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v8, v13), offset * 5 + (v8.X - v13.X) / 2, 270, dimensionStyle);
                dim8.UserText = "SD_3 = " + Math.Round(sd3 / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v13, v1), offset * 7 + (v13.X - v2.X) / 2 + 0.25 + v7.X - v13.X, 270, dimensionStyle);
                dim9.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(v25, v2), offset + 0.5, 0, dimensionStyle);
                dim10.UserText = "DMM = " + Math.Round(dmm / scale, 2);
                dxf.AddEntity(dim10);
                //尺寸11
                Angular2LineDimension angdim11 = new Angular2LineDimension(new Line(v16, v17), new Line(v11, v10), offset / 2, dimensionStyle);
                angdim11.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim11);
                //尺寸12
                Angular2LineDimension angdim12 = new Angular2LineDimension(new Line(v18, v19), new Line(v9, v8), offset / 2, dimensionStyle);
                angdim12.UserText = "STA_3 = " + Math.Round(sta3 / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim12);
                //尺寸13
                LinearDimension dim13 = new LinearDimension(new Line(v9, v10), offset * 4 + v7.X - v9.X, 270, dimensionStyle);
                dim13.UserText = "SDL_2 = " + Math.Round(sdl2 / scale, 2);
                dxf.AddEntity(dim13);
                //尺寸14
                LinearDimension dim14 = new LinearDimension(new Line(v6, v13), offset * 6 + (v7.X - v13.X) / 2 + v7.X - v6.X, 270, dimensionStyle);
                dim14.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                dxf.AddEntity(dim14);
            }
            if (ccms == "ZYL" && dc3 == 0)
            {
                //坐标
                Vector2 v1 = new Vector2(dmm / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(dmm / 2, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - (dmm - dn) / 2);
                Vector2 v5 = new Vector2(v4.X, -oal + lcf);
                Vector2 v6 = new Vector2((dc2 - dn) / 4 + v5.X, v5.Y);
                Vector2 v7 = new Vector2(dc2 / 2, v6.Y - (dc2 / 2 - v6.X));
                Vector2 v8 = new Vector2(v7.X, -oal + sd2);
                Vector2 v9 = new Vector2(dc1 / 2, -oal + sdl1 + (dc1 - dcintf) / 2 / Math.Tan(sig / 2));
                Vector2 v10 = new Vector2(v9.X, v9.Y - sdl1);
                Vector2 v11 = new Vector2(dcintf / 2, -oal);
                Vector2 v12 = new Vector2(-v11.X, v11.Y);
                Vector2 v13 = new Vector2(-v10.X, v10.Y);
                Vector2 v14 = new Vector2(-v9.X, v9.Y);
                Vector2 v15 = new Vector2(-v8.X, v8.Y);
                Vector2 v16 = new Vector2(-v7.X, v7.Y);
                Vector2 v17 = new Vector2(-v6.X, v6.Y);
                Vector2 v18 = new Vector2(-v5.X, v5.Y);
                Vector2 v19 = new Vector2(-v4.X, v4.Y);
                Vector2 v20 = new Vector2(-v3.X, v3.Y);
                Vector2 v21 = new Vector2(-v2.X, v2.Y);
                Vector2 v22 = new Vector2(-v1.X, v1.Y);
                Vector2 v23 = new Vector2(0, 2);
                Vector2 v24 = new Vector2(0, -oal - 2);
                Vector2 v25 = new Vector2(v12.X, v11.Y - 2 * (v11.X / Math.Tan(sig / 2)));
                Vector2 v26 = new Vector2(-v25.X, v25.Y);
                //线段
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                LwPolyline Arc1 = new LwPolyline();
                Arc1.Vertexes.Add(new LwPolylineVertex(v3));
                Arc1.Vertexes.Add(new LwPolylineVertex(v4));
                Arc1.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc1, 0.3, contour);
                LwPolyline Arc2 = new LwPolyline();
                Arc2.Vertexes.Add(new LwPolylineVertex(v19));
                Arc2.Vertexes.Add(new LwPolylineVertex(v20));
                Arc2.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc2, 0.3, contour);
                Vector2[] Line3 = { v4, v5 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v5, v6 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v6, v7 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v7, v8 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v8, v9 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v9, v10 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v10, v11 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v11, v12 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v12, v13 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v13, v14 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v14, v15 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v15, v16 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v16, v17 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v17, v18 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v18, v19 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v20, v21 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v21, v22 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                Vector2[] Line20 = { v22, v1 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v21, v2 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v20, v3 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v19, v4 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v18, v5 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Vector2[] Line25 = { v16, v7 };
                fun.drawBLine(dxf, Line25, 0.3, contour);
                Vector2[] Line26 = { v15, v8 };
                fun.drawBLine(dxf, Line26, 0.3, contour);
                Vector2[] Line27 = { v14, v9 };
                fun.drawBLine(dxf, Line27, 0.3, contour);
                Vector2[] Line28 = { v13, v10 };
                fun.drawBLine(dxf, Line28, 0.3, contour);
                Vector2[] Line29 = { v23, v24 };
                fun.drawPlinetype(dxf, Line29, 0.15, centre, Linetype.Center);
                Line Line30 = new Line(v11, v25);
                Line Line31 = new Line(v12, v26);
                //主视图图层
                Line30.Layer = dimensioning;
                Line31.Layer = dimensioning;
                //主视图
                dxf.AddEntity(Line30);
                dxf.AddEntity(Line31);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 2.5;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                Angular2LineDimension angdim1 = new Angular2LineDimension(Line30, Line31, offset / 2, dimensionStyle);
                angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v13, v10), -(v10.Y - v11.Y) - offset * 3, 0, dimensionStyle);
                dim2.UserText = "DC_1 = " + Math.Round(dc1 / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v15, v8), -v8.Y + v11.Y - offset * 4, 0, dimensionStyle);
                dim3.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v12, v11), -offset * 2 - 4, 0, dimensionStyle);
                dim5.UserText = "DCINTF = " + Math.Round(dcintf / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v1, v3), offset + 0.25, 270, dimensionStyle);
                dim6.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                LinearDimension dim7 = new LinearDimension(new Line(v9, v10), offset * 3 + v7.X - v10.X, 270, dimensionStyle);
                dim7.UserText = "SDL_1 = " + Math.Round(sdl1 / scale, 2);
                dxf.AddEntity(dim7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v8, v11), offset * 4 + (v8.X - v11.X) / 2, 270, dimensionStyle);
                dim8.UserText = "SD_2 = " + Math.Round(sd2 / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v11, v1), offset * 6 + (v11.X - v2.X) / 2 + 0.25 + v7.X - v11.X, 270, dimensionStyle);
                dim9.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(v21, v2), offset + 0.5, 0, dimensionStyle);
                dim10.UserText = "DMM = " + Math.Round(dmm / scale, 2);
                dxf.AddEntity(dim10);
                //尺寸11
                Angular2LineDimension angdim11 = new Angular2LineDimension(new Line(v14, v15), new Line(v9, v8), offset / 2, dimensionStyle);
                angdim11.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim11);
                //尺寸14
                LinearDimension dim14 = new LinearDimension(new Line(v6, v11), offset * 5 + (v7.X - v11.X) / 2 + v7.X - v6.X, 270, dimensionStyle);
                dim14.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                dxf.AddEntity(dim14);
            }
            if (ccms == "MKG" || ccms == "MEG")
            {
                if (dc3 != 0)
                {
                    ls = (db - ds) / tg;
                    //坐标
                    Vector2 v1 = new Vector2(ds / 2 - 0.5, 0);
                    Vector2 v2 = new Vector2(ds / 2 + Math.Sqrt(0.25 / (1 + tg * tg / 4)) * tg / 2, -Math.Sqrt(0.25 / (1 + tg * tg / 4)));
                    Vector2 v3 = new Vector2(db / 2, -ls);
                    Vector2 v4 = new Vector2(dn / 2, v3.Y - (db - dn) / 2);
                    Vector2 v5 = new Vector2(v4.X, -oal + lcf);
                    Vector2 v6 = new Vector2((dc3 - dn) / 4 + v5.X, v5.Y);
                    Vector2 v7 = new Vector2(dc3 / 2, v6.Y - (dc3 / 2 - v6.X));
                    Vector2 v8 = new Vector2(v7.X, -oal + sd3);
                    Vector2 v9 = new Vector2(dc2 / 2, -oal + sd2 + sdl2);
                    Vector2 v10 = new Vector2(v9.X, -oal + sd2);
                    Vector2 v12 = new Vector2(dc1 / 2, -oal + (dc1 - dcintf) / 2 / Math.Tan(sig / 2));
                    Vector2 v11 = new Vector2(v12.X, v12.Y + sdl1);
                    Vector2 v13 = new Vector2(dcintf / 2, -oal);
                    Vector2 v14 = new Vector2(-v13.X, v13.Y);
                    Vector2 v15 = new Vector2(-v12.X, v12.Y);
                    Vector2 v16 = new Vector2(-v11.X, v11.Y);
                    Vector2 v17 = new Vector2(-v10.X, v10.Y);
                    Vector2 v18 = new Vector2(-v9.X, v9.Y);
                    Vector2 v19 = new Vector2(-v8.X, v8.Y);
                    Vector2 v20 = new Vector2(-v7.X, v7.Y);
                    Vector2 v21 = new Vector2(-v6.X, v6.Y);
                    Vector2 v22 = new Vector2(-v5.X, v5.Y);
                    Vector2 v23 = new Vector2(-v4.X, v4.Y);
                    Vector2 v24 = new Vector2(-v3.X, v3.Y);
                    Vector2 v25 = new Vector2(-v2.X, v2.Y);
                    Vector2 v26 = new Vector2(-v1.X, v1.Y);
                    Vector2 v27 = new Vector2(0, 2);
                    Vector2 v28 = new Vector2(0, -oal - 2);
                    Vector2 v29 = new Vector2(v14.X, v13.Y - 2 * (v13.X / Math.Tan(sig / 2)));
                    Vector2 v30 = new Vector2(-v29.X, v29.Y);
                    //线段
                    Vector2[] Line1 = { v1, v2 };
                    fun.drawBLine(dxf, Line1, 0.3, contour);
                    Vector2[] Line2 = { v2, v3 };
                    fun.drawBLine(dxf, Line2, 0.3, contour);
                    LwPolyline Arc1 = new LwPolyline();
                    Arc1.Vertexes.Add(new LwPolylineVertex(v3));
                    Arc1.Vertexes.Add(new LwPolylineVertex(v4));
                    Arc1.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                    fun.PolyFill(dxf, Arc1, 0.3, contour);
                    LwPolyline Arc2 = new LwPolyline();
                    Arc2.Vertexes.Add(new LwPolylineVertex(v23));
                    Arc2.Vertexes.Add(new LwPolylineVertex(v24));
                    Arc2.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                    fun.PolyFill(dxf, Arc2, 0.3, contour);
                    Vector2[] Line3 = { v4, v5 };
                    fun.drawBLine(dxf, Line3, 0.3, contour);
                    Vector2[] Line4 = { v5, v6 };
                    fun.drawBLine(dxf, Line4, 0.3, contour);
                    Vector2[] Line5 = { v6, v7 };
                    fun.drawBLine(dxf, Line5, 0.3, contour);
                    Vector2[] Line6 = { v7, v8 };
                    fun.drawBLine(dxf, Line6, 0.3, contour);
                    Vector2[] Line7 = { v8, v9 };
                    fun.drawBLine(dxf, Line7, 0.3, contour);
                    Vector2[] Line8 = { v9, v10 };
                    fun.drawBLine(dxf, Line8, 0.3, contour);
                    Vector2[] Line9 = { v10, v11 };
                    fun.drawBLine(dxf, Line9, 0.3, contour);
                    Vector2[] Line10 = { v11, v12 };
                    fun.drawBLine(dxf, Line10, 0.3, contour);
                    Vector2[] Line11 = { v12, v13 };
                    fun.drawBLine(dxf, Line11, 0.3, contour);
                    Vector2[] Line12 = { v13, v14 };
                    fun.drawBLine(dxf, Line12, 0.3, contour);
                    Vector2[] Line13 = { v14, v15 };
                    fun.drawBLine(dxf, Line13, 0.3, contour);
                    Vector2[] Line14 = { v15, v16 };
                    fun.drawBLine(dxf, Line14, 0.3, contour);
                    Vector2[] Line15 = { v16, v17 };
                    fun.drawBLine(dxf, Line15, 0.3, contour);
                    Vector2[] Line16 = { v17, v18 };
                    fun.drawBLine(dxf, Line16, 0.3, contour);
                    Vector2[] Line17 = { v18, v19 };
                    fun.drawBLine(dxf, Line17, 0.3, contour);
                    Vector2[] Line18 = { v19, v20 };
                    fun.drawBLine(dxf, Line18, 0.3, contour);
                    Vector2[] Line19 = { v20, v21 };
                    fun.drawBLine(dxf, Line19, 0.3, contour);
                    Vector2[] Line20 = { v21, v22 };
                    fun.drawBLine(dxf, Line20, 0.3, contour);
                    Vector2[] Line21 = { v22, v23 };
                    fun.drawBLine(dxf, Line21, 0.3, contour);
                    Vector2[] Line22 = { v24, v25 };
                    fun.drawBLine(dxf, Line22, 0.3, contour);
                    Vector2[] Line23 = { v25, v26 };
                    fun.drawBLine(dxf, Line23, 0.3, contour);
                    Vector2[] Line24 = { v26, v1 };
                    fun.drawBLine(dxf, Line24, 0.3, contour);
                    Vector2[] Line25 = { v25, v2 };
                    fun.drawBLine(dxf, Line25, 0.3, contour);
                    Vector2[] Line26 = { v24, v3 };
                    fun.drawBLine(dxf, Line26, 0.3, contour);
                    Vector2[] Line27 = { v23, v4 };
                    fun.drawBLine(dxf, Line27, 0.3, contour);
                    Vector2[] Line28 = { v22, v5 };
                    fun.drawBLine(dxf, Line28, 0.3, contour);
                    Vector2[] Line29 = { v20, v7 };
                    fun.drawBLine(dxf, Line29, 0.3, contour);
                    Vector2[] Line30 = { v19, v8 };
                    fun.drawBLine(dxf, Line30, 0.3, contour);
                    Vector2[] Line31 = { v18, v9 };
                    fun.drawBLine(dxf, Line31, 0.3, contour);
                    Vector2[] Line32 = { v17, v10 };
                    fun.drawBLine(dxf, Line32, 0.3, contour);
                    Vector2[] Line33 = { v16, v11 };
                    fun.drawBLine(dxf, Line33, 0.3, contour);
                    Vector2[] Line34 = { v15, v12 };
                    fun.drawBLine(dxf, Line34, 0.3, contour);
                    Vector2[] Line35 = { v27, v28 };
                    fun.drawPlinetype(dxf, Line35, 0.15, centre, Linetype.Center);
                    Line Line36 = new Line(v13, v29);
                    Line Line37 = new Line(v14, v30);
                    //主视图图层
                    Line36.Layer = dimensioning;
                    Line37.Layer = dimensioning;
                    //主视图
                    dxf.AddEntity(Line36);
                    dxf.AddEntity(Line37);
                    //标注样式
                    //箭头样式
                    DimensionStyle dimensionStyle = fun.CreateDimStyle();
                    dimensionStyle.ArrowSize = 0.2;
                    dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                    dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                    //文本样式
                    dimensionStyle.TextHeight = 2.5;
                    double offset = 10;
                    //线段尺寸标注
                    //尺寸1
                    Angular2LineDimension angdim1 = new Angular2LineDimension(Line36, Line37, offset / 2, dimensionStyle);
                    angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim1);
                    //尺寸2
                    LinearDimension dim2 = new LinearDimension(new Line(v15, v12), -(v12.Y - v13.Y) - offset * 3, 0, dimensionStyle);
                    dim2.UserText = "DC_1 = " + Math.Round(dc1 / scale, 2);
                    dxf.AddEntity(dim2);
                    //尺寸3
                    LinearDimension dim3 = new LinearDimension(new Line(v17, v10), -v10.Y + v13.Y - offset * 4, 0, dimensionStyle);
                    dim3.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                    dxf.AddEntity(dim3);
                    //尺寸4
                    LinearDimension dim4 = new LinearDimension(new Line(v19, v8), -sd3 - offset * 5, 0, dimensionStyle);
                    dim4.UserText = "DC_3 = " + Math.Round(dc3 / scale, 2);
                    dxf.AddEntity(dim4);
                    //尺寸5
                    LinearDimension dim5 = new LinearDimension(new Line(v14, v13), -offset * 2 - 4, 0, dimensionStyle);
                    dim5.UserText = "DCINTF = " + Math.Round(dcintf / scale, 2);
                    dxf.AddEntity(dim5);
                    //尺寸7
                    LinearDimension dim7 = new LinearDimension(new Line(v11, v12), offset * 3 + v7.X - v11.X, 270, dimensionStyle);
                    dim7.UserText = "SDL_1 = " + Math.Round(sdl1 / scale, 2);
                    dxf.AddEntity(dim7);
                    //尺寸8
                    LinearDimension dim8 = new LinearDimension(new Line(v8, v13), offset * 5 + (v8.X - v13.X) / 2, 270, dimensionStyle);
                    dim8.UserText = "SD_3 = " + Math.Round(sd3 / scale, 2);
                    dxf.AddEntity(dim8);
                    //尺寸9
                    LinearDimension dim9 = new LinearDimension(new Line(v13, v1), offset * 7 + (v13.X - v2.X) / 2 + 0.25 + v7.X - v13.X, 270, dimensionStyle);
                    dim9.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim9);
                    //尺寸11
                    Angular2LineDimension angdim11 = new Angular2LineDimension(new Line(v16, v17), new Line(v11, v10), offset / 2, dimensionStyle);
                    angdim11.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim11);
                    //尺寸12
                    Angular2LineDimension angdim12 = new Angular2LineDimension(new Line(v18, v19), new Line(v9, v8), offset / 2, dimensionStyle);
                    angdim12.UserText = "STA_3 = " + Math.Round(sta3 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim12);
                    //尺寸13
                    LinearDimension dim13 = new LinearDimension(new Line(v9, v10), offset * 4 + v7.X - v9.X, 270, dimensionStyle);
                    dim13.UserText = "SDL_2 = " + Math.Round(sdl2 / scale, 2);
                    dxf.AddEntity(dim13);
                    //尺寸14
                    LinearDimension dim14 = new LinearDimension(new Line(v6, v13), offset * 6 + (v7.X - v13.X) / 2 + v7.X - v6.X, 270, dimensionStyle);
                    dim14.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                    dxf.AddEntity(dim14);
                }
                if (dc3 == 0)
                {
                    ls = (db - ds) / tg;
                    //坐标
                    Vector2 v1 = new Vector2(ds / 2 - 0.5, 0);
                    Vector2 v2 = new Vector2(ds / 2 + Math.Sqrt(0.25 / (1 + tg * tg / 4)) * tg / 2, -Math.Sqrt(0.25 / (1 + tg * tg / 4)));
                    Vector2 v3 = new Vector2(db / 2, -ls);
                    Vector2 v4 = new Vector2(dn / 2, v3.Y - (db - dn) / 2);
                    Vector2 v5 = new Vector2(v4.X, -oal + lcf);
                    Vector2 v6 = new Vector2((dc2 - dn) / 4 + v5.X, v5.Y);
                    Vector2 v7 = new Vector2(dc2 / 2, v6.Y - (dc2 / 2 - v6.X));
                    Vector2 v8 = new Vector2(v7.X, -oal + sd2);
                    Vector2 v9 = new Vector2(dc1 / 2, -oal + sdl1 + (dc1 - dcintf) / 2 / Math.Tan(sig / 2));
                    Vector2 v10 = new Vector2(v9.X, v9.Y - sdl1);
                    Vector2 v11 = new Vector2(dcintf / 2, -oal);
                    Vector2 v12 = new Vector2(-v11.X, v11.Y);
                    Vector2 v13 = new Vector2(-v10.X, v10.Y);
                    Vector2 v14 = new Vector2(-v9.X, v9.Y);
                    Vector2 v15 = new Vector2(-v8.X, v8.Y);
                    Vector2 v16 = new Vector2(-v7.X, v7.Y);
                    Vector2 v17 = new Vector2(-v6.X, v6.Y);
                    Vector2 v18 = new Vector2(-v5.X, v5.Y);
                    Vector2 v19 = new Vector2(-v4.X, v4.Y);
                    Vector2 v20 = new Vector2(-v3.X, v3.Y);
                    Vector2 v21 = new Vector2(-v2.X, v2.Y);
                    Vector2 v22 = new Vector2(-v1.X, v1.Y);
                    Vector2 v23 = new Vector2(0, 2);
                    Vector2 v24 = new Vector2(0, -oal - 2);
                    Vector2 v25 = new Vector2(v12.X, v11.Y - 2 * (v11.X / Math.Tan(sig / 2)));
                    Vector2 v26 = new Vector2(-v25.X, v25.Y);
                    //线段
                    Vector2[] Line1 = { v1, v2 };
                    fun.drawBLine(dxf, Line1, 0.3, contour);
                    Vector2[] Line2 = { v2, v3 };
                    fun.drawBLine(dxf, Line2, 0.3, contour);
                    LwPolyline Arc1 = new LwPolyline();
                    Arc1.Vertexes.Add(new LwPolylineVertex(v3));
                    Arc1.Vertexes.Add(new LwPolylineVertex(v4));
                    Arc1.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                    fun.PolyFill(dxf, Arc1, 0.3, contour);
                    LwPolyline Arc2 = new LwPolyline();
                    Arc2.Vertexes.Add(new LwPolylineVertex(v19));
                    Arc2.Vertexes.Add(new LwPolylineVertex(v20));
                    Arc2.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                    fun.PolyFill(dxf, Arc2, 0.3, contour);
                    Vector2[] Line3 = { v4, v5 };
                    fun.drawBLine(dxf, Line3, 0.3, contour);
                    Vector2[] Line4 = { v5, v6 };
                    fun.drawBLine(dxf, Line4, 0.3, contour);
                    Vector2[] Line5 = { v6, v7 };
                    fun.drawBLine(dxf, Line5, 0.3, contour);
                    Vector2[] Line6 = { v7, v8 };
                    fun.drawBLine(dxf, Line6, 0.3, contour);
                    Vector2[] Line7 = { v8, v9 };
                    fun.drawBLine(dxf, Line7, 0.3, contour);
                    Vector2[] Line8 = { v9, v10 };
                    fun.drawBLine(dxf, Line8, 0.3, contour);
                    Vector2[] Line9 = { v10, v11 };
                    fun.drawBLine(dxf, Line9, 0.3, contour);
                    Vector2[] Line10 = { v11, v12 };
                    fun.drawBLine(dxf, Line10, 0.3, contour);
                    Vector2[] Line11 = { v12, v13 };
                    fun.drawBLine(dxf, Line11, 0.3, contour);
                    Vector2[] Line12 = { v13, v14 };
                    fun.drawBLine(dxf, Line12, 0.3, contour);
                    Vector2[] Line13 = { v14, v15 };
                    fun.drawBLine(dxf, Line13, 0.3, contour);
                    Vector2[] Line14 = { v15, v16 };
                    fun.drawBLine(dxf, Line14, 0.3, contour);
                    Vector2[] Line15 = { v16, v17 };
                    fun.drawBLine(dxf, Line15, 0.3, contour);
                    Vector2[] Line16 = { v17, v18 };
                    fun.drawBLine(dxf, Line16, 0.3, contour);
                    Vector2[] Line17 = { v18, v19 };
                    fun.drawBLine(dxf, Line17, 0.3, contour);
                    Vector2[] Line18 = { v20, v21 };
                    fun.drawBLine(dxf, Line18, 0.3, contour);
                    Vector2[] Line19 = { v21, v22 };
                    fun.drawBLine(dxf, Line19, 0.3, contour);
                    Vector2[] Line20 = { v22, v1 };
                    fun.drawBLine(dxf, Line20, 0.3, contour);
                    Vector2[] Line21 = { v21, v2 };
                    fun.drawBLine(dxf, Line21, 0.3, contour);
                    Vector2[] Line22 = { v20, v3 };
                    fun.drawBLine(dxf, Line22, 0.3, contour);
                    Vector2[] Line23 = { v19, v4 };
                    fun.drawBLine(dxf, Line23, 0.3, contour);
                    Vector2[] Line24 = { v18, v5 };
                    fun.drawBLine(dxf, Line24, 0.3, contour);
                    Vector2[] Line25 = { v16, v7 };
                    fun.drawBLine(dxf, Line25, 0.3, contour);
                    Vector2[] Line26 = { v15, v8 };
                    fun.drawBLine(dxf, Line26, 0.3, contour);
                    Vector2[] Line27 = { v14, v9 };
                    fun.drawBLine(dxf, Line27, 0.3, contour);
                    Vector2[] Line28 = { v13, v10 };
                    fun.drawBLine(dxf, Line28, 0.3, contour);
                    Vector2[] Line29 = { v23, v24 };
                    fun.drawPlinetype(dxf, Line29, 0.15, centre, Linetype.Center);
                    Line Line30 = new Line(v11, v25);
                    Line Line31 = new Line(v12, v26);
                    //主视图图层
                    Line30.Layer = dimensioning;
                    Line31.Layer = dimensioning;
                    //主视图
                    dxf.AddEntity(Line30);
                    dxf.AddEntity(Line31);
                    //标注样式
                    //箭头样式
                    DimensionStyle dimensionStyle = fun.CreateDimStyle();
                    dimensionStyle.ArrowSize = 0.2;
                    dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                    dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                    //文本样式
                    dimensionStyle.TextHeight = 2.5;
                    double offset = 10;
                    //线段尺寸标注
                    //尺寸1
                    Angular2LineDimension angdim1 = new Angular2LineDimension(Line30, Line31, offset / 2, dimensionStyle);
                    angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim1);
                    //尺寸2
                    LinearDimension dim2 = new LinearDimension(new Line(v13, v10), -(v10.Y - v11.Y) - offset * 3, 0, dimensionStyle);
                    dim2.UserText = "DC_1 = " + Math.Round(dc1 / scale, 2);
                    dxf.AddEntity(dim2);
                    //尺寸3
                    LinearDimension dim3 = new LinearDimension(new Line(v15, v8), -v8.Y + v11.Y - offset * 4, 0, dimensionStyle);
                    dim3.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                    dxf.AddEntity(dim3);
                    //尺寸5
                    LinearDimension dim5 = new LinearDimension(new Line(v12, v11), -offset * 2 - 4, 0, dimensionStyle);
                    dim5.UserText = "DCINTF = " + Math.Round(dcintf / scale, 2);
                    dxf.AddEntity(dim5);
                    //尺寸7
                    LinearDimension dim7 = new LinearDimension(new Line(v9, v10), offset * 3 + v7.X - v10.X, 270, dimensionStyle);
                    dim7.UserText = "SDL_1 = " + Math.Round(sdl1 / scale, 2);
                    dxf.AddEntity(dim7);
                    //尺寸8
                    LinearDimension dim8 = new LinearDimension(new Line(v8, v11), offset * 4 + (v8.X - v11.X) / 2, 270, dimensionStyle);
                    dim8.UserText = "SD_2 = " + Math.Round(sd2 / scale, 2);
                    dxf.AddEntity(dim8);
                    //尺寸9
                    LinearDimension dim9 = new LinearDimension(new Line(v11, v1), offset * 6 + (v11.X - v2.X) / 2 + 0.25 + v7.X - v11.X, 270, dimensionStyle);
                    dim9.UserText = "OAL = " + Math.Round(oal / scale, 2);
                    dxf.AddEntity(dim9);
                    //尺寸11
                    Angular2LineDimension angdim11 = new Angular2LineDimension(new Line(v14, v15), new Line(v9, v8), offset / 2, dimensionStyle);
                    angdim11.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                    dxf.AddEntity(angdim11);
                    //尺寸14
                    LinearDimension dim14 = new LinearDimension(new Line(v6, v11), offset * 5 + (v7.X - v11.X) / 2 + v7.X - v6.X, 270, dimensionStyle);
                    dim14.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                    dxf.AddEntity(dim14);
                }
            }
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 200 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void TaperedCountersinkingTool(Dictionary<string, Object> data)  //锥形锪孔刀具
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double dc1 = Convert.ToDouble(data["dc1"]) * scale;
            double dc2 = Convert.ToDouble(data["dc2"]) * scale;
            double dn = Convert.ToDouble(data["dn"]) * scale;
            double lcf = Convert.ToDouble(data["lcf"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double dmm = Convert.ToDouble(data["dmm"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double sig = Convert.ToDouble(data["sig"]) * pi / 180;
            string ccms = Convert.ToString(data["ccms"]);
            double czc = Convert.ToDouble(data["czc"]);
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            double db = Convert.ToDouble(data["db"]) * scale;
            double ds = Convert.ToDouble(data["ds"]) * scale;
            double TG = Convert.ToDouble(data["tg"]);
            if (ccms == "MKG")
            {
                if (czc == 0)
                {
                    db = 9.045 * scale;
                    ds = 6.4 * scale;
                    TG = 0.05205;
                }
                if (czc == 1)
                {
                    db = 12.065 * scale;
                    ds = 9.4 * scale;
                    TG = 0.04988;
                }
                if (czc == 2)
                {
                    db = 17.78 * scale;
                    ds = 14.6 * scale;
                    TG = 0.04995;
                }
                if (czc == 3)
                {
                    db = 23.825 * scale;
                    ds = 19.8 * scale;
                    TG = 0.05020;
                }
                if (czc == 4)
                {
                    db = 31.267 * scale;
                    ds = 25.9 * scale;
                    TG = 0.05194;
                }
                if (czc == 5)
                {
                    db = 44.399 * scale;
                    ds = 37.6 * scale;
                    TG = 0.05263;
                }
                if (czc == 6)
                {
                    db = 63.348 * scale;
                    ds = 53.9 * scale;
                    TG = 0.05214;
                }
            }
            if (ccms == "MEG")
            {
                TG = 0.05;
                if (czc == 4)
                {
                    db = 4 * scale;
                    ds = 2.9 * scale;
                }
                if (czc == 6)
                {
                    db = 6 * scale;
                    ds = 4.4 * scale;
                }
                if (czc == 80)
                {
                    db = 80 * scale;
                    ds = 70.2 * scale;
                }
                if (czc == 100)
                {
                    db = 100 * scale;
                    ds = 88.4 * scale;
                }
                if (czc == 120)
                {
                    db = 120 * scale;
                    ds = 106.6 * scale;
                }
                if (czc == 160)
                {
                    db = 160 * scale;
                    ds = 143 * scale;
                }
                if (czc == 200)
                {
                    db = 200 * scale;
                    ds = 179.4 * scale;
                }
            }
            //主视图
            if (ccms == "ZYL")
            {
                //坐标
                Vector2 v1 = new Vector2(dmm / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(dmm / 2, -0.5);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - (dmm - dn) / 2);
                Vector2 v5 = new Vector2(v4.X, -oal + lcf);
                Vector2 v6 = new Vector2(dc2 / 2 - lcf + (dc2 - dc1) / 2 / Math.Tan(sig / 2), v5.Y);
                Vector2 v7 = new Vector2(dc2 / 2, -oal + (dc2 - dc1) / 2 / Math.Tan(sig / 2));
                Vector2 v8 = new Vector2(dc1 / 2, -oal);
                Vector2 v9 = new Vector2(-v8.X, v8.Y);
                Vector2 v10 = new Vector2(-v7.X, v7.Y);
                Vector2 v11 = new Vector2(-v6.X, v6.Y);
                Vector2 v12 = new Vector2(-v5.X, v5.Y);
                Vector2 v13 = new Vector2(-v4.X, v4.Y);
                Vector2 v14 = new Vector2(-v3.X, v3.Y);
                Vector2 v15 = new Vector2(-v2.X, v2.Y);
                Vector2 v16 = new Vector2(-v1.X, v1.Y);
                Vector2 v17 = new Vector2(0, 2);
                Vector2 v18 = new Vector2(0, -oal - 2);
                Vector2 v19 = new Vector2(lcf * Math.Tan(sig / 2) + v8.X, v6.Y);
                Vector2 v20 = new Vector2(-v19.X, v19.Y);
                //线段
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                LwPolyline Arc1 = new LwPolyline();
                Arc1.Vertexes.Add(new LwPolylineVertex(v3));
                Arc1.Vertexes.Add(new LwPolylineVertex(v4));
                Arc1.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc1, 0.3, contour);
                LwPolyline Arc2 = new LwPolyline();
                Arc2.Vertexes.Add(new LwPolylineVertex(v13));
                Arc2.Vertexes.Add(new LwPolylineVertex(v14));
                Arc2.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc2, 0.3, contour);
                Vector2[] Line3 = { v4, v5 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v5, v6 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v6, v7 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v7, v8 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v8, v9 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v9, v10 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v10, v11 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v11, v12 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v12, v13 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v14, v15 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v15, v16 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v16, v1 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v15, v2 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v14, v3 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v13, v4 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v12, v5 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v10, v7 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                Vector2[] Line20 = { v17, v18 };
                fun.drawPlinetype(dxf, Line20, 0.15, centre, Linetype.Center);
                Line Line21 = new Line(v20, v9);
                Line Line22 = new Line(v19, v8);
                //主视图图层
                Line21.Layer = dimensioning;
                Line22.Layer = dimensioning;
                //主视图
                dxf.AddEntity(Line21);
                dxf.AddEntity(Line22);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 2.5;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                Angular2LineDimension angdim1 = new Angular2LineDimension(Line22, Line21, offset / 2, dimensionStyle);
                angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v9, v8), -offset, 0, dimensionStyle);
                dim2.UserText = "DC_1 = " + Math.Round(dc1 / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v10, v7), -v7.Y + v8.Y - offset * 3, 0, dimensionStyle);
                dim3.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v1, v3), offset + 0.25, 270, dimensionStyle);
                dim6.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v8, v1), offset * 2 + (v8.X - v2.X) / 2 + 0.25 + v7.X - v8.X, 270, dimensionStyle);
                dim9.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                LinearDimension dim10 = new LinearDimension(new Line(v15, v2), offset + 0.5, 0, dimensionStyle);
                dim10.UserText = "DMM = " + Math.Round(dmm / scale, 2);
                dxf.AddEntity(dim10);
                //尺寸14
                LinearDimension dim14 = new LinearDimension(new Line(v6, v8), offset / 2 + (v7.X - v8.X) / 2 + v7.X - v6.X, 270, dimensionStyle);
                dim14.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                dxf.AddEntity(dim14);
            }
            if (ccms == "MKG" || ccms == "MEG")
            {
                ls = (db - ds) / TG;
                //坐标
                Vector2 v1 = new Vector2(ds / 2 - 0.5, 0);
                Vector2 v2 = new Vector2(ds / 2 + Math.Sqrt(0.25 / (1 + TG * TG / 4)) * TG / 2, -Math.Sqrt(0.25 / (1 + TG * TG / 4)));
                Vector2 v3 = new Vector2(db / 2, -ls);
                Vector2 v4 = new Vector2(dn / 2, v3.Y - (db - dn) / 2);
                Vector2 v5 = new Vector2(v4.X, -oal + lcf);
                Vector2 v6 = new Vector2(dc2 / 2 - lcf + (dc2 - dc1) / 2 / Math.Tan(sig / 2), v5.Y);
                Vector2 v7 = new Vector2(dc2 / 2, -oal + (dc2 - dc1) / 2 / Math.Tan(sig / 2));
                Vector2 v8 = new Vector2(dc1 / 2, -oal);
                Vector2 v9 = new Vector2(-v8.X, v8.Y);
                Vector2 v10 = new Vector2(-v7.X, v7.Y);
                Vector2 v11 = new Vector2(-v6.X, v6.Y);
                Vector2 v12 = new Vector2(-v5.X, v5.Y);
                Vector2 v13 = new Vector2(-v4.X, v4.Y);
                Vector2 v14 = new Vector2(-v3.X, v3.Y);
                Vector2 v15 = new Vector2(-v2.X, v2.Y);
                Vector2 v16 = new Vector2(-v1.X, v1.Y);
                Vector2 v17 = new Vector2(0, 2);
                Vector2 v18 = new Vector2(0, -oal - 2);
                Vector2 v19 = new Vector2(lcf * Math.Tan(sig / 2) + v8.X, v6.Y);
                Vector2 v20 = new Vector2(-v19.X, v19.Y);
                //线段
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                LwPolyline Arc1 = new LwPolyline();
                Arc1.Vertexes.Add(new LwPolylineVertex(v3));
                Arc1.Vertexes.Add(new LwPolylineVertex(v4));
                Arc1.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc1, 0.3, contour);
                LwPolyline Arc2 = new LwPolyline();
                Arc2.Vertexes.Add(new LwPolylineVertex(v13));
                Arc2.Vertexes.Add(new LwPolylineVertex(v14));
                Arc2.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc2, 0.3, contour);
                Vector2[] Line3 = { v4, v5 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v5, v6 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v6, v7 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v7, v8 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v8, v9 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v9, v10 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v10, v11 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v11, v12 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v12, v13 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v14, v15 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v15, v16 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v16, v1 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v15, v2 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v14, v3 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v13, v4 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v12, v5 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v10, v7 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                Vector2[] Line20 = { v17, v18 };
                fun.drawPlinetype(dxf, Line20, 0.15, centre, Linetype.Center);
                Line Line21 = new Line(v20, v9);
                Line Line22 = new Line(v19, v8);
                //主视图图层
                Line21.Layer = dimensioning;
                Line22.Layer = dimensioning;
                //主视图
                dxf.AddEntity(Line21);
                dxf.AddEntity(Line22);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 2.5;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                Angular2LineDimension angdim1 = new Angular2LineDimension(Line22, Line21, offset / 2, dimensionStyle);
                angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v9, v8), -offset, 0, dimensionStyle);
                dim2.UserText = "DC_1 = " + Math.Round(dc1 / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v10, v7), -v7.Y + v8.Y - offset * 3, 0, dimensionStyle);
                dim3.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v8, v1), offset * 2 + (v8.X - v2.X) / 2 + 0.25 + v7.X - v8.X, 270, dimensionStyle);
                dim9.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸14
                LinearDimension dim14 = new LinearDimension(new Line(v6, v8), offset / 2 + (v7.X - v8.X) / 2 + v7.X - v6.X, 270, dimensionStyle);
                dim14.UserText = "LCF = " + Math.Round(lcf / scale, 2);
                dxf.AddEntity(dim14);
            }
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, 200 - oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void SpotDrill(Dictionary<string, Object> data)  //定心钻
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dmm = Convert.ToDouble(data["dmm"]) * scale;
            if (dmm == 0)
            {
                dmm = dc;
            }
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double sig = Convert.ToDouble(data["sig"]) * pi / 180;
            double pl = Convert.ToDouble(data["pl"]) * scale;
            if (pl == 0)
            {
                pl = dc / 2 / Math.Tan(sig / 2);
            }
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            Vector2 v2 = new Vector2(dmm / 2, -0.5);
            Vector2 v1 = new Vector2(v2.X - 0.5, 0);
            Vector2 v3 = new Vector2(v2.X, -ls);
            Vector2 v4 = new Vector2(dc / 2, v3.Y - (dmm - dc) / 2);
            Vector2 v5 = new Vector2(v4.X, -oal + pl);
            Vector2 v6 = new Vector2(pl * Math.Tan(sig / 2), v5.Y);
            Vector2 v7 = new Vector2(0, -oal);
            Vector2 v8 = new Vector2(-v6.X, v6.Y);
            Vector2 v9 = new Vector2(-v5.X, v5.Y);
            Vector2 v10 = new Vector2(-v4.X, v4.Y);
            Vector2 v11 = new Vector2(-v3.X, v3.Y);
            Vector2 v12 = new Vector2(-v2.X, v2.Y);
            Vector2 v13 = new Vector2(-v1.X, v1.Y);
            Vector2 v14 = new Vector2(0, 2);
            Vector2 v15 = new Vector2(0, -oal - 2);
            Vector2 v16 = new Vector2(v8.X, 2 * v7.Y - v8.Y);
            Vector2 v17 = new Vector2(v6.X, 2 * v7.Y - v6.Y);
            //线段
            //主视图
            if ((dmm - dc) != 0)
            {
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                LwPolyline Arc1 = new LwPolyline();
                Arc1.Vertexes.Add(new LwPolylineVertex(v3));
                Arc1.Vertexes.Add(new LwPolylineVertex(v4));
                Arc1.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc1, 0.3, contour);
                LwPolyline Arc2 = new LwPolyline();
                Arc2.Vertexes.Add(new LwPolylineVertex(v10));
                Arc2.Vertexes.Add(new LwPolylineVertex(v11));
                Arc2.Vertexes[0].Bulge = (1 - Math.Cos(pi / 4)) * 2 * Math.Cos(pi / 4);
                fun.PolyFill(dxf, Arc2, 0.3, contour);
                Vector2[] Line3 = { v4, v5 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v5, v6 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v6, v7 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v7, v8 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v8, v9 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v9, v10 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v11, v12 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v12, v13 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v13, v1 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v2, v12 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v3, v11 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v4, v10 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v6, v8 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
            }
            if ((dmm - dc) == 0)
            {
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v5 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v5, v6 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v6, v7 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v7, v8 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v8, v9 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v9, v12 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v12, v13 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v13, v1 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v12, v2 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v8, v6 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
            }
            Vector2[] Line16 = { v14, v15 };
            fun.drawPlinetype(dxf, Line16, 0.15, centre, Linetype.Center);
            Line Line17 = new Line(v7, v16);
            Line Line18 = new Line(v7, v17);
            //主视图图层
            Line17.Layer = dimensioning;
            Line18.Layer = dimensioning;
            //主视图
            dxf.AddEntity(Line17);
            dxf.AddEntity(Line18);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            Angular2LineDimension angdim1 = new Angular2LineDimension(new Line(v7, v16), new Line(v7, v17), offset / 2, dimensionStyle);
            angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
            dxf.AddEntity(angdim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v9, v5), -pl - offset - 5, 0, dimensionStyle);
            dim2.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            LinearDimension dim3 = new LinearDimension(new Line(v7, v5), offset + v2.X - v5.X / 2, 270, dimensionStyle);
            dim3.UserText = "PL = " + Math.Round(pl / scale, 2);
            dxf.AddEntity(dim3);
            //尺寸4
            if ((dmm - dc) != 0)
            {
                LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
            }
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v7, v1), offset * 2 + v1.X / 2, 270, dimensionStyle);
            dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            if ((dmm - dc) != 0)
            {
                LinearDimension dim6 = new LinearDimension(new Line(v12, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DMM = " + Math.Round(dmm / scale, 2);
                dxf.AddEntity(dim6);
            }
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(v7.X - 148.5, v7.Y + 210 + oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void CentreDrill(Dictionary<string, Object> data)  //中心钻
        {
            DxfDocument dxf = new DxfDocument();
            dxf.Layers["0"].Lineweight = Lineweight.W25;
            Layer contour = new Layer("contour");//轮廓层
            Layer dimensioning = new Layer("dimensioning");//尺寸层
            Layer refin = new Layer("refin");//基准线/内轮廓/虚线
            Layer center = new Layer("center");//中心线
            Layer textlayer = new Layer("textlayer");//文本层
            Layer hatching = new Layer("hatching");//填充层
            Layer additionalline = new Layer("additionalline");//附加线
            Layer cutting = new Layer("cutting");//切削层
            fun.SetLayer(dxf);
            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 67)
            {
                scale = 4.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 134)
            {
                scale = 2.0;
            }
            else if (scale == 0 && soal < 178)
            {
                scale = 1.5;
            }
            else if (scale == 0 && soal < 268)
            {
                scale = 1.0;
            }
            else if (scale == 0 && soal < 357)
            {
                scale = 0.75;
            }
            else if (scale == 0)
            {
                scale = 0.5;
            }
            double pi = Math.PI;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double ls = Convert.ToDouble(data["ls"]) * scale;
            double sig = Convert.ToDouble(data["sig"]) * pi / 180;
            double dc1 = Convert.ToDouble(data["dc1"]) * scale;
            double dc2 = Convert.ToDouble(data["dc2"]) * scale;
            double dmm = Convert.ToDouble(data["dmm"]) * scale;
            if (dmm == 0)
            {
                dmm = dc2;
            }
            double sdl1 = Convert.ToDouble(data["sdl1"]) * scale;
            double sta2 = Convert.ToDouble(data["sta2"]) * pi / 180;
            double rcsk = Convert.ToDouble(data["rcsk"]) * scale;
            double sigcsk = Convert.ToDouble(data["sigcsk"]) * pi / 180;
            double pl = (dc1 / 2) / Math.Tan(sig / 2);
            double sd2 = Convert.ToDouble(data["sd2"]) * scale;
            double al = Math.Sqrt((dc2 - dc1) * (dc2 - dc1) / 4 + (sd2 - pl - sdl1) * (sd2 - pl - sdl1));
            double ah = rcsk - Math.Sqrt(rcsk * rcsk - al * al / 4);
            double deg2 = 2 * Math.Asin(al / 2 / rcsk);
            double deg1 = (pi - deg2) / 2 - Math.Atan((sd2 - pl - sdl1) / (dc2 - dc1) * 2);
            double deg3 = (pi - deg1 - deg2) / pi * 180;
            double deg4 = (pi - deg1) / pi * 180;
            double nce = Convert.ToDouble(data["nce"]);
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //主视图
            if (nce == 1 && rcsk == 0 && sigcsk == 0)//单端A型
            {
                Vector2 v2 = new Vector2(dmm / 2, -0.5);
                Vector2 v1 = new Vector2(v2.X - 0.5, 0);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dc2 / 2, v3.Y - (dmm - dc2) / 2);
                Vector2 v5 = new Vector2(v4.X, -oal + pl + sdl1 + (dc2 - dc1) / 2 / Math.Tan(sta2 / 2));
                Vector2 v6 = new Vector2(dc1 / 2, -oal + pl + sdl1);
                Vector2 v7 = new Vector2(v6.X, -oal + pl);
                Vector2 v8 = new Vector2(0, -oal);
                Vector2 v9 = new Vector2(-v7.X, v7.Y);
                Vector2 v10 = new Vector2(-v6.X, v6.Y);
                Vector2 v11 = new Vector2(-v5.X, v5.Y);
                Vector2 v12 = new Vector2(-v4.X, v4.Y);
                Vector2 v13 = new Vector2(-v3.X, v3.Y);
                Vector2 v14 = new Vector2(-v2.X, v2.Y);
                Vector2 v15 = new Vector2(-v1.X, v1.Y);
                Vector2 v16 = new Vector2(0, 2);
                Vector2 v17 = new Vector2(0, -oal - 2);
                Vector2 v18 = new Vector2(v9.X, 2 * v8.Y - v9.Y);
                Vector2 v19 = new Vector2(v7.X, 2 * v8.Y - v7.Y);
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v7, v8 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v8, v9 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v9, v10 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v10, v11 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v11, v12 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v12, v13 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v15 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v15, v1 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v13, v3 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v12, v4 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v11, v5 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v10, v6 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                Vector2[] Line20 = { v9, v7 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v14, v2 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v16, v17 };
                fun.drawPlinetype(dxf, Line22, 0.15, center, Linetype.Center);
                Line Line23 = new Line(v8, v18);
                Line Line24 = new Line(v8, v19);
                Line23.Layer = dimensioning;
                Line24.Layer = dimensioning;
                dxf.AddEntity(Line23);
                dxf.AddEntity(Line24);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                Angular2LineDimension angdim1 = new Angular2LineDimension(Line23, Line24, offset / 2, dimensionStyle);
                angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v9, v7), -v7.Y + v8.Y - offset - 5, 0, dimensionStyle);
                dim2.UserText = "DC_1 = " + Math.Round(dc1 / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v11, v5), -v5.Y + v8.Y - offset * 2, 0, dimensionStyle);
                dim3.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 3 + v1.X / 2 + 0.5, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v14, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DMM = " + Math.Round(dmm / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                Angular2LineDimension angdim7 = new Angular2LineDimension(new Line(v10, v11), new Line(v6, v5), offset, dimensionStyle);
                angdim7.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v6, v7), offset + v2.X - v6.X, 270, dimensionStyle);
                dim8.UserText = "SDL_1 = " + Math.Round(sdl1 / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v5, v8), offset * 2 + v5.X / 2 + v2.X - v5.X, 270, dimensionStyle);
                dim9.UserText = "SD_2 = " + Math.Round(sd2 / scale, 2);
                dxf.AddEntity(dim9);
                //图框
                if (isframe == 1)
                {
                    Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(v8.X - 148.5, v8.Y + 210 + oal / 2));
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            if (nce == 1 && rcsk == 0 && sigcsk != 0)//单端B型
            {
                Vector2 v2 = new Vector2(dmm / 2, -0.5);
                Vector2 v1 = new Vector2(v2.X - 0.5, 0);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dc2 / 2, v3.Y - (dmm - dc2) / 2);
                Vector2 v5 = new Vector2(v4.X, -oal + sd2);
                Vector2 v6 = new Vector2(v5.X - (2 * (sd2 - pl - sdl1) * Math.Tan(sta2 / 2) * Math.Tan(sigcsk / 2) - (dc2 - dc1) * Math.Tan(sta2 / 2)) / 2 / (Math.Tan(sigcsk / 2) - Math.Tan(sta2 / 2)), v5.Y - (v5.X - (v5.X - (2 * (sd2 - pl - sdl1) * Math.Tan(sta2 / 2) * Math.Tan(sigcsk / 2) - (dc2 - dc1) * Math.Tan(sta2 / 2)) / 2 / (Math.Tan(sigcsk / 2) - Math.Tan(sta2 / 2)))) / Math.Tan(sta2 / 2));
                Vector2 v7 = new Vector2(dc1 / 2, -oal + pl + sdl1);
                Vector2 v8 = new Vector2(v7.X, -oal + pl);
                Vector2 v9 = new Vector2(0, -oal);
                Vector2 v10 = new Vector2(-v8.X, v8.Y);
                Vector2 v11 = new Vector2(-v7.X, v7.Y);
                Vector2 v12 = new Vector2(-v6.X, v6.Y);
                Vector2 v13 = new Vector2(-v5.X, v5.Y);
                Vector2 v14 = new Vector2(-v4.X, v4.Y);
                Vector2 v15 = new Vector2(-v3.X, v3.Y);
                Vector2 v16 = new Vector2(-v2.X, v2.Y);
                Vector2 v17 = new Vector2(-v1.X, v1.Y);
                Vector2 v18 = new Vector2(0, 2);
                Vector2 v19 = new Vector2(0, -oal - 2);
                Vector2 v20 = new Vector2(v10.X, 2 * v9.Y - v10.Y);
                Vector2 v21 = new Vector2(v8.X, 2 * v9.Y - v8.Y);
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v7, v8 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v8, v9 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v9, v10 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v10, v11 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v11, v12 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v12, v13 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v15 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v15, v16 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v16, v17 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v17, v1 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v16, v2 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v15, v3 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                Vector2[] Line20 = { v14, v4 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v13, v5 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v12, v6 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v11, v7 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v10, v8 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Vector2[] Line25 = { v18, v19 };
                fun.drawPlinetype(dxf, Line25, 0.15, center, Linetype.Center);
                Line Line26 = new Line(v9, v20);
                Line Line27 = new Line(v9, v21);
                Line26.Layer = dimensioning;
                Line27.Layer = dimensioning;
                dxf.AddEntity(Line26);
                dxf.AddEntity(Line27);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                Angular2LineDimension angdim1 = new Angular2LineDimension(Line26, Line27, offset / 2, dimensionStyle);
                angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v10, v8), -v8.Y + v9.Y - offset - 5, 0, dimensionStyle);
                dim2.UserText = "DC_1 = " + Math.Round(dc1 / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v13, v5), -v5.Y + v9.Y - offset * 2, 0, dimensionStyle);
                dim3.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v9, v1), offset * 3 + v1.X / 2 + 0.5, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v16, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DMM = " + Math.Round(dmm / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                Angular2LineDimension angdim7 = new Angular2LineDimension(new Line(v12, v13), new Line(v6, v5), offset, dimensionStyle);
                angdim7.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v7, v8), offset + v2.X - v7.X, 270, dimensionStyle);
                dim8.UserText = "SDL_1 = " + Math.Round(sdl1 / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v5, v9), offset * 2 + v5.X / 2 + v2.X - v5.X, 270, dimensionStyle);
                dim9.UserText = "SD_2 = " + Math.Round(sd2 / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                Angular2LineDimension angdim10 = new Angular2LineDimension(new Line(v11, v12), new Line(v7, v6), offset, dimensionStyle);
                angdim10.UserText = "SIGCSK = " + Math.Round(sigcsk / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim10);
                //图框
                if (isframe == 1)
                {
                    Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(v9.X - 148.5, v9.Y + 210 + oal / 2));
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            if (nce == 1 && rcsk != 0)//单端R型
            {
                Vector2 v2 = new Vector2(dmm / 2, -0.5);
                Vector2 v1 = new Vector2(v2.X - 0.5, 0);
                Vector2 v3 = new Vector2(v2.X, -ls);
                Vector2 v4 = new Vector2(dc2 / 2, v3.Y - (dmm - dc2) / 2);
                Vector2 v5 = new Vector2(v4.X, -oal + sd2);
                Vector2 v6 = new Vector2(dc1 / 2, -oal + pl + sdl1);
                Vector2 v7 = new Vector2(v6.X, -oal + pl);
                Vector2 v8 = new Vector2(0, -oal);
                Vector2 v9 = new Vector2(-v7.X, v7.Y);
                Vector2 v10 = new Vector2(-v6.X, v6.Y);
                Vector2 v11 = new Vector2(-v5.X, v5.Y);
                Vector2 v12 = new Vector2(-v4.X, v4.Y);
                Vector2 v13 = new Vector2(-v3.X, v3.Y);
                Vector2 v14 = new Vector2(-v2.X, v2.Y);
                Vector2 v15 = new Vector2(-v1.X, v1.Y);
                Vector2 v16 = new Vector2(0, 2);
                Vector2 v17 = new Vector2(0, -oal - 2);
                Vector2 v18 = new Vector2(v9.X, 2 * v8.Y - v9.Y);
                Vector2 v19 = new Vector2(v7.X, 2 * v8.Y - v7.Y);
                Vector2 v20 = new Vector2(v6.X + rcsk * Math.Cos(deg1), v6.Y - rcsk * Math.Sin(deg1));
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                LwPolyline Arc1 = new LwPolyline();
                Arc1.Vertexes.Add(new LwPolylineVertex(v5));
                Arc1.Vertexes.Add(new LwPolylineVertex(v6));
                Arc1.Vertexes[0].Bulge = 2 * ah / al;
                fun.PolyFill(dxf, Arc1, 0.3, contour);
                LwPolyline Arc2 = new LwPolyline();
                Arc2.Vertexes.Add(new LwPolylineVertex(v10));
                Arc2.Vertexes.Add(new LwPolylineVertex(v11));
                Arc2.Vertexes[0].Bulge = 2 * ah / al;
                fun.PolyFill(dxf, Arc2, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v7, v8 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v8, v9 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v9, v10 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v11, v12 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v12, v13 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v13, v14 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v14, v15 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v15, v1 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v14, v2 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v13, v3 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v12, v4 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v11, v5 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v10, v6 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                Vector2[] Line20 = { v9, v7 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v16, v17 };
                fun.drawPlinetype(dxf, Line21, 0.15, center, Linetype.Center);
                Line Line22 = new Line(v8, v18);
                Line Line23 = new Line(v8, v19);
                Line22.Layer = dimensioning;
                Line23.Layer = dimensioning;
                dxf.AddEntity(Line22);
                dxf.AddEntity(Line23);
                Arc arc1 = new Arc(v20, rcsk, deg3, deg4);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                Angular2LineDimension angdim1 = new Angular2LineDimension(Line22, Line23, offset / 2, dimensionStyle);
                angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v9, v7), -v7.Y + v8.Y - offset - 5, 0, dimensionStyle);
                dim2.UserText = "DC_1 = " + Math.Round(dc1 / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v11, v5), -v5.Y + v8.Y - offset * 2, 0, dimensionStyle);
                dim3.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸4
                LinearDimension dim4 = new LinearDimension(new Line(v1, v3), offset + 0.25, 270, dimensionStyle);
                dim4.UserText = "LS = " + Math.Round(ls / scale, 2);
                dxf.AddEntity(dim4);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 3 + v1.X / 2 + 0.5, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸6
                LinearDimension dim6 = new LinearDimension(new Line(v14, v2), offset + 0.5, 0, dimensionStyle);
                dim6.UserText = "DMM = " + Math.Round(dmm / scale, 2);
                dxf.AddEntity(dim6);
                //尺寸7
                RadialDimension dimrad7 = new RadialDimension(arc1, 135, rcsk / scale * 3, dimensionStyle);
                dimrad7.UserText = "RCSK = " + Math.Round(rcsk / scale, 2);
                dxf.AddEntity(dimrad7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v6, v7), offset + v2.X - v6.X, 270, dimensionStyle);
                dim8.UserText = "SDL_1 = " + Math.Round(sdl1 / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v5, v8), offset * 2 + v5.X / 2 + v2.X - v5.X, 270, dimensionStyle);
                dim9.UserText = "SD_2 = " + Math.Round(sd2 / scale, 2);
                dxf.AddEntity(dim9);
                //图框
                if (isframe == 1)
                {
                    Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(v8.X - 148.5, v8.Y + 210 + oal / 2));
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            if (nce == 2 && rcsk == 0 && sigcsk == 0)//双端A型
            {
                Vector2 v1 = new Vector2(0, -oal);
                Vector2 v2 = new Vector2(dc1 / 2, pl - oal);
                Vector2 v3 = new Vector2(v2.X, -oal + pl + sdl1);
                Vector2 v4 = new Vector2(dc2 / 2, v3.Y + (dc2 - dc1) / 2 / Math.Tan(sta2 / 2));
                Vector2 v8 = new Vector2(v1.X, 0);
                Vector2 v7 = new Vector2(v2.X, -pl);
                Vector2 v6 = new Vector2(v7.X, -pl - sdl1);
                Vector2 v5 = new Vector2(v4.X, v6.Y - (dc2 - dc1) / 2 / Math.Tan(sta2 / 2));
                Vector2 v9 = new Vector2(-v7.X, v7.Y);
                Vector2 v10 = new Vector2(-v6.X, v6.Y);
                Vector2 v11 = new Vector2(-v5.X, v5.Y);
                Vector2 v12 = new Vector2(-v4.X, v4.Y);
                Vector2 v13 = new Vector2(-v3.X, v3.Y);
                Vector2 v14 = new Vector2(-v2.X, v2.Y);
                Vector2 v15 = new Vector2(0, 2);
                Vector2 v16 = new Vector2(0, -oal - 2);
                Vector2 v17 = new Vector2(v9.X, 2 * v8.Y - v9.Y);
                Vector2 v18 = new Vector2(v7.X, 2 * v8.Y - v7.Y);
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v7, v8 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v8, v9 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v9, v10 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v10, v11 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v11, v12 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v12, v13 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v1 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v9, v7 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v10, v6 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v11, v5 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v12, v4 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v13, v3 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                Vector2[] Line20 = { v14, v2 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v15, v16 };
                fun.drawPlinetype(dxf, Line21, 0.15, center, Linetype.Center);
                Line Line22 = new Line(v8, v17);
                Line Line23 = new Line(v8, v18);
                Line22.Layer = dimensioning;
                Line23.Layer = dimensioning;
                dxf.AddEntity(Line22);
                dxf.AddEntity(Line23);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                Angular2LineDimension angdim1 = new Angular2LineDimension(Line22, Line23, offset, dimensionStyle);
                angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v14, v2), -v2.Y + v1.Y - offset, 0, dimensionStyle);
                dim2.UserText = "DC_1 = " + Math.Round(dc1 / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v12, v4), -v4.Y + v1.Y - offset * 2, 0, dimensionStyle);
                dim3.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 3 + v5.X, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸7
                Angular2LineDimension angdim7 = new Angular2LineDimension(new Line(v10, v11), new Line(v6, v5), -offset, dimensionStyle);
                angdim7.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v6, v7), offset + v5.X - v6.X, 270, dimensionStyle);
                dim8.UserText = "SDL_1 = " + Math.Round(sdl1 / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v5, v8), offset * 2 + v5.X / 2, 270, dimensionStyle);
                dim9.UserText = "SD_2 = " + Math.Round(sd2 / scale, 2);
                dxf.AddEntity(dim9);
                //图框
                if (isframe == 1)
                {
                    Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(v1.X - 148.5, v1.Y + 210 + oal / 2));
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            if (nce == 2 && rcsk == 0 && sigcsk != 0)//双端B型
            {
                Vector2 v1 = new Vector2(0, -oal);
                Vector2 v2 = new Vector2(dc1 / 2, -oal + pl);
                Vector2 v3 = new Vector2(v2.X, -oal + pl + sdl1);
                Vector2 v5 = new Vector2(dc2 / 2, -oal + sd2);
                Vector2 v4 = new Vector2(v5.X - (2 * (sd2 - pl - sdl1) * Math.Tan(sta2 / 2) * Math.Tan(sigcsk / 2) - (dc2 - dc1) * Math.Tan(sta2 / 2)) / 2 / (Math.Tan(sigcsk / 2) - Math.Tan(sta2 / 2)), v5.Y - (v5.X - (v5.X - (2 * (sd2 - pl - sdl1) * Math.Tan(sta2 / 2) * Math.Tan(sigcsk / 2) - (dc2 - dc1) * Math.Tan(sta2 / 2)) / 2 / (Math.Tan(sigcsk / 2) - Math.Tan(sta2 / 2)))) / Math.Tan(sta2 / 2));
                Vector2 v10 = new Vector2(v1.X, 0);
                Vector2 v9 = new Vector2(v2.X, -pl);
                Vector2 v8 = new Vector2(v3.X, -pl - sdl1);
                Vector2 v7 = new Vector2(v4.X, -oal - v4.Y);
                Vector2 v6 = new Vector2(v5.X, -sd2);
                Vector2 v11 = new Vector2(-v9.X, v9.Y);
                Vector2 v12 = new Vector2(-v8.X, v8.Y);
                Vector2 v13 = new Vector2(-v7.X, v7.Y);
                Vector2 v14 = new Vector2(-v6.X, v6.Y);
                Vector2 v15 = new Vector2(-v5.X, v5.Y);
                Vector2 v16 = new Vector2(-v4.X, v4.Y);
                Vector2 v17 = new Vector2(-v3.X, v3.Y);
                Vector2 v18 = new Vector2(-v2.X, v2.Y);
                Vector2 v19 = new Vector2(0, 2);
                Vector2 v20 = new Vector2(0, -oal - 2);
                Vector2 v21 = new Vector2(v11.X, 2 * v10.Y - v11.Y);
                Vector2 v22 = new Vector2(v9.X, 2 * v10.Y - v9.Y);
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v3, v4 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                Vector2[] Line4 = { v4, v5 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v5, v6 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v6, v7 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v7, v8 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v8, v9 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v9, v10 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v10, v11 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v11, v12 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v12, v13 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v13, v14 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v14, v15 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v15, v16 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v16, v17 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v17, v18 };
                fun.drawBLine(dxf, Line17, 0.3, contour);
                Vector2[] Line18 = { v18, v1 };
                fun.drawBLine(dxf, Line18, 0.3, contour);
                Vector2[] Line19 = { v11, v9 };
                fun.drawBLine(dxf, Line19, 0.3, contour);
                Vector2[] Line20 = { v12, v8 };
                fun.drawBLine(dxf, Line20, 0.3, contour);
                Vector2[] Line21 = { v13, v7 };
                fun.drawBLine(dxf, Line21, 0.3, contour);
                Vector2[] Line22 = { v14, v6 };
                fun.drawBLine(dxf, Line22, 0.3, contour);
                Vector2[] Line23 = { v15, v5 };
                fun.drawBLine(dxf, Line23, 0.3, contour);
                Vector2[] Line24 = { v16, v4 };
                fun.drawBLine(dxf, Line24, 0.3, contour);
                Vector2[] Line25 = { v17, v3 };
                fun.drawBLine(dxf, Line25, 0.3, contour);
                Vector2[] Line26 = { v18, v2 };
                fun.drawBLine(dxf, Line26, 0.3, contour);
                Vector2[] Line27 = { v19, v20 };
                fun.drawPlinetype(dxf, Line27, 0.15, center, Linetype.Center);
                Line Line28 = new Line(v10, v21);
                Line Line29 = new Line(v10, v22);
                Line28.Layer = dimensioning;
                Line29.Layer = dimensioning;
                dxf.AddEntity(Line28);
                dxf.AddEntity(Line29);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                Angular2LineDimension angdim1 = new Angular2LineDimension(Line28, Line29, offset, dimensionStyle);
                angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v18, v2), -v2.Y + v1.Y - offset, 0, dimensionStyle);
                dim2.UserText = "DC_1 = " + Math.Round(dc1 / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v15, v5), -v5.Y + v1.Y - offset * 2, 0, dimensionStyle);
                dim3.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v10, v1), offset * 3 + v6.X, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸7
                Angular2LineDimension angdim7 = new Angular2LineDimension(new Line(v13, v14), new Line(v7, v6), -offset * 2, dimensionStyle);
                angdim7.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v8, v9), offset + v6.X - v8.X, 270, dimensionStyle);
                dim8.UserText = "SDL_1 = " + Math.Round(sdl1 / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v6, v10), offset * 2 + v6.X / 2, 270, dimensionStyle);
                dim9.UserText = "SD_2 = " + Math.Round(sd2 / scale, 2);
                dxf.AddEntity(dim9);
                //尺寸10
                Angular2LineDimension angdim10 = new Angular2LineDimension(new Line(v12, v13), new Line(v8, v7), -offset, dimensionStyle);
                angdim10.UserText = "SIGCSK = " + Math.Round(sigcsk / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim10);
                //图框
                if (isframe == 1)
                {
                    Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(v1.X - 148.5, v1.Y + 210 + oal / 2));
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            if (nce == 2 && rcsk != 0)//双端R型
            {
                Vector2 v1 = new Vector2(0, -oal);
                Vector2 v2 = new Vector2(dc1 / 2, -oal + pl);
                Vector2 v3 = new Vector2(v2.X, pl + sdl1 - oal);
                Vector2 v4 = new Vector2(dc2 / 2, -oal + sd2);
                Vector2 v5 = new Vector2(v4.X, -sd2);
                Vector2 v6 = new Vector2(v3.X, -pl - sdl1);
                Vector2 v7 = new Vector2(v2.X, -pl);
                Vector2 v8 = new Vector2(0, 0);
                Vector2 v9 = new Vector2(-v7.X, v7.Y);
                Vector2 v10 = new Vector2(-v6.X, v6.Y);
                Vector2 v11 = new Vector2(-v5.X, v5.Y);
                Vector2 v12 = new Vector2(-v4.X, v4.Y);
                Vector2 v13 = new Vector2(-v3.X, v3.Y);
                Vector2 v14 = new Vector2(-v2.X, v2.Y);
                Vector2 v15 = new Vector2(0, 2);
                Vector2 v16 = new Vector2(0, -oal - 2);
                Vector2 v17 = new Vector2(v9.X, 2 * v8.Y - v9.Y);
                Vector2 v18 = new Vector2(v7.X, 2 * v8.Y - v7.Y);
                Vector2 v19 = new Vector2(v3.X + rcsk * Math.Cos(deg1), v3.Y - rcsk * Math.Sin(deg1));
                Vector2[] Line1 = { v1, v2 };
                fun.drawBLine(dxf, Line1, 0.3, contour);
                Vector2[] Line2 = { v2, v3 };
                fun.drawBLine(dxf, Line2, 0.3, contour);
                Vector2[] Line3 = { v4, v5 };
                fun.drawBLine(dxf, Line3, 0.3, contour);
                LwPolyline Arc1 = new LwPolyline();
                Arc1.Vertexes.Add(new LwPolylineVertex(v4));
                Arc1.Vertexes.Add(new LwPolylineVertex(v3));
                Arc1.Vertexes[0].Bulge = 2 * ah / al;
                fun.PolyFill(dxf, Arc1, 0.3, contour);
                LwPolyline Arc2 = new LwPolyline();
                Arc2.Vertexes.Add(new LwPolylineVertex(v6));
                Arc2.Vertexes.Add(new LwPolylineVertex(v5));
                Arc2.Vertexes[0].Bulge = 2 * ah / al;
                fun.PolyFill(dxf, Arc2, 0.3, contour);
                LwPolyline Arc3 = new LwPolyline();
                Arc3.Vertexes.Add(new LwPolylineVertex(v11));
                Arc3.Vertexes.Add(new LwPolylineVertex(v10));
                Arc3.Vertexes[0].Bulge = 2 * ah / al;
                fun.PolyFill(dxf, Arc3, 0.3, contour);
                LwPolyline Arc4 = new LwPolyline();
                Arc4.Vertexes.Add(new LwPolylineVertex(v13));
                Arc4.Vertexes.Add(new LwPolylineVertex(v12));
                Arc4.Vertexes[0].Bulge = 2 * ah / al;
                fun.PolyFill(dxf, Arc4, 0.3, contour);
                Vector2[] Line4 = { v6, v7 };
                fun.drawBLine(dxf, Line4, 0.3, contour);
                Vector2[] Line5 = { v7, v8 };
                fun.drawBLine(dxf, Line5, 0.3, contour);
                Vector2[] Line6 = { v8, v9 };
                fun.drawBLine(dxf, Line6, 0.3, contour);
                Vector2[] Line7 = { v9, v10 };
                fun.drawBLine(dxf, Line7, 0.3, contour);
                Vector2[] Line8 = { v11, v12 };
                fun.drawBLine(dxf, Line8, 0.3, contour);
                Vector2[] Line9 = { v13, v14 };
                fun.drawBLine(dxf, Line9, 0.3, contour);
                Vector2[] Line10 = { v14, v1 };
                fun.drawBLine(dxf, Line10, 0.3, contour);
                Vector2[] Line11 = { v14, v2 };
                fun.drawBLine(dxf, Line11, 0.3, contour);
                Vector2[] Line12 = { v13, v3 };
                fun.drawBLine(dxf, Line12, 0.3, contour);
                Vector2[] Line13 = { v12, v4 };
                fun.drawBLine(dxf, Line13, 0.3, contour);
                Vector2[] Line14 = { v11, v5 };
                fun.drawBLine(dxf, Line14, 0.3, contour);
                Vector2[] Line15 = { v10, v6 };
                fun.drawBLine(dxf, Line15, 0.3, contour);
                Vector2[] Line16 = { v9, v7 };
                fun.drawBLine(dxf, Line16, 0.3, contour);
                Vector2[] Line17 = { v15, v16 };
                fun.drawPlinetype(dxf, Line17, 0.15, center, Linetype.Center);
                Line Line18 = new Line(v8, v17);
                Line Line19 = new Line(v8, v18);
                Line18.Layer = dimensioning;
                Line19.Layer = dimensioning;
                dxf.AddEntity(Line18);
                dxf.AddEntity(Line19);
                Arc arc1 = new Arc(v19, rcsk, deg3, deg4);
                //标注样式
                //箭头样式
                DimensionStyle dimensionStyle = fun.CreateDimStyle();
                dimensionStyle.ArrowSize = 0.2;
                dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
                dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
                //文本样式
                dimensionStyle.TextHeight = 1.0;
                double offset = 10;
                //线段尺寸标注
                //尺寸1
                Angular2LineDimension angdim1 = new Angular2LineDimension(Line18, Line19, offset, dimensionStyle);
                angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
                dxf.AddEntity(angdim1);
                //尺寸2
                LinearDimension dim2 = new LinearDimension(new Line(v14, v2), -v2.Y + v1.Y - offset, 0, dimensionStyle);
                dim2.UserText = "DC_1 = " + Math.Round(dc1 / scale, 2);
                dxf.AddEntity(dim2);
                //尺寸3
                LinearDimension dim3 = new LinearDimension(new Line(v12, v4), -v4.Y + v1.Y - offset * 2, 0, dimensionStyle);
                dim3.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
                dxf.AddEntity(dim3);
                //尺寸5
                LinearDimension dim5 = new LinearDimension(new Line(v8, v1), offset * 3 + v5.X, 270, dimensionStyle);
                dim5.UserText = "OAL = " + Math.Round(oal / scale, 2);
                dxf.AddEntity(dim5);
                //尺寸7
                RadialDimension dimrad7 = new RadialDimension(arc1, 135, rcsk / scale * 3, dimensionStyle);
                dimrad7.UserText = "RCSK = " + Math.Round(rcsk / scale, 2);
                dxf.AddEntity(dimrad7);
                //尺寸8
                LinearDimension dim8 = new LinearDimension(new Line(v6, v7), offset + v5.X - v6.X, 270, dimensionStyle);
                dim8.UserText = "SDL_1 = " + Math.Round(sdl1 / scale, 2);
                dxf.AddEntity(dim8);
                //尺寸9
                LinearDimension dim9 = new LinearDimension(new Line(v5, v8), offset * 2 + v5.X / 2, 270, dimensionStyle);
                dim9.UserText = "SD_2 = " + Math.Round(sd2 / scale, 2);
                dxf.AddEntity(dim9);
                //图框
                if (isframe == 1)
                {
                    Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(v1.X - 148.5, v1.Y + 210 + oal / 2));
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }
            //定义格式，根据路径导出

            fun.SetLayer(dxf);
            fun.SetByLayer(dxf);

            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void ShellCoreDrill(Dictionary<string, Object> data)  //套式扩孔钻
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 18)
            {
                scale = 15.0;
            }
            else if (scale == 0 && soal < 27)
            {
                scale = 10.0;
            }
            else if (scale == 0 && soal < 54)
            {
                scale = 5.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 135)
            {
                scale = 2.0;
            }
            else if (scale == 0)
            {
                scale = 1.0;
            }
            double pi = Math.PI;
            double df = Convert.ToDouble(data["df"]) * scale;
            double dccb = Convert.ToDouble(data["dccb"]) * scale;
            double lccb = Convert.ToDouble(data["lccb"]) * scale;
            double dcb = Convert.ToDouble(data["dcb"]) * scale;
            double sig = Convert.ToDouble(data["sig"]) * pi / 180;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dcintf = Convert.ToDouble(data["dcintf"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double lu = Convert.ToDouble(data["lu"]) * scale;
            double isframe = Convert.ToDouble(data["isframe"]);
            double lf = oal - (dc - dcintf) / 2 / Math.Tan(sig / 2);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            Vector2 v1 = new Vector2(dccb / 2, 0);
            Vector2 v2 = new Vector2(df / 2, 0);
            Vector2 v3 = new Vector2(v2.X, -oal + lu);
            Vector2 v4 = new Vector2(dc / 2, v3.Y);
            Vector2 v5 = new Vector2(v4.X, -lf);
            Vector2 v6 = new Vector2(dcintf / 2, -oal);
            Vector2 v7 = new Vector2(dcb / 2, v6.Y);
            Vector2 v8 = new Vector2(v7.X, -lccb);
            Vector2 v9 = new Vector2(v1.X, v8.Y);
            Vector2 v10 = new Vector2(0, v8.Y);
            Vector2 v11 = new Vector2(-v1.X, v1.Y);
            Vector2 v12 = new Vector2(-v9.X, v9.Y);
            Vector2 v13 = new Vector2(-v8.X, v8.Y);
            Vector2 v14 = new Vector2(-v7.X, v7.Y);
            Vector2 v15 = new Vector2(-v6.X, v6.Y);
            Vector2 v16 = new Vector2(-v5.X, v5.Y);
            Vector2 v17 = new Vector2(-v4.X, v4.Y);
            Vector2 v18 = new Vector2(-v3.X, v3.Y);
            Vector2 v19 = new Vector2(-v2.X, v2.Y);
            Vector2 v20 = new Vector2(0, 2);
            Vector2 v21 = new Vector2(0, -oal - 2);
            Vector2 v22 = new Vector2(0, v6.Y - dcintf / 2 / Math.Tan(sig / 2));
            Vector2 v23 = new Vector2(v15.X, v22.Y * 2 - v15.Y);
            Vector2 v24 = new Vector2(v6.X, v22.Y * 2 - v6.Y);
            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v15 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v15, v16 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v16, v17 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v17, v18 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v18, v19 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v19, v2 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v1, v9 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v9, v10 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v8, v7 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v16, new Vector2(0, v16.Y) };
            fun.drawBLine(dxf, Line15, 0.3, contour);
            Vector2[] Line16 = { v18, new Vector2(0, v18.Y) };
            fun.drawBLine(dxf, Line16, 0.3, contour);
            Vector2[] Line17 = { v11, v12 };
            fun.drawPlinetype(dxf, Line17, 0.15, refin, Linetype.Dashed);
            Vector2[] Line18 = { v12, v10 };
            fun.drawPlinetype(dxf, Line18, 0.15, refin, Linetype.Dashed);
            Vector2[] Line19 = { v13, v14 };
            fun.drawPlinetype(dxf, Line19, 0.15, refin, Linetype.Dashed);
            Vector2[] Line20 = { v20, v21 };
            fun.drawPlinetype(dxf, Line20, 0.15, centre, Linetype.Center);
            Line Line21 = new Line(v6, v23);
            Line Line22 = new Line(v15, v24);
            Line21.Layer = dimensioning;
            Line22.Layer = dimensioning;
            dxf.AddEntity(Line21);
            dxf.AddEntity(Line22);
            //填充
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v1));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v2));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v3));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v4));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v5));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v6));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v7));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v8));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v9));
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsubofline(dxf, htype1, hnumst1, 45, oal / scale / 2, hline1, hatching);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            Angular2LineDimension angdim1 = new Angular2LineDimension(Line21, Line22, offset / 2, dimensionStyle);
            angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
            dxf.AddEntity(angdim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v15, v6), v22.Y - v6.Y - offset - 5, 0, dimensionStyle);
            dim2.UserText = "DCINTF = " + Math.Round(dcintf / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            LinearDimension dim3 = new LinearDimension(new Line(v16, v5), v22.Y - v5.Y - offset * 2, 0, dimensionStyle);
            dim3.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim3);
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(v19, v16), -offset - (v5.X - v2.X) / 2, 270, dimensionStyle);
            dim4.UserText = "LF = " + Math.Round(lf / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v2, v6), offset * 3 + v5.X - (v2.X + v6.X) / 2, 270, dimensionStyle);
            dim5.UserText = "OAL.LPR = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v13, v8), offset + lccb, 0, dimensionStyle);
            dim6.UserText = "DCB = " + Math.Round(dcb / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸7
            LinearDimension dim7 = new LinearDimension(new Line(v11, v1), offset * 2, 0, dimensionStyle);
            dim7.UserText = "DCCB = " + Math.Round(dccb / scale, 2);
            dxf.AddEntity(dim7);
            //尺寸8
            LinearDimension dim8 = new LinearDimension(new Line(v19, v2), offset * 3, 0, dimensionStyle);
            dim8.UserText = "DF = " + Math.Round(df / scale, 2);
            dxf.AddEntity(dim8);
            //尺寸9
            LinearDimension dim9 = new LinearDimension(new Line(v1, v9), offset + v4.X - v1.X, 270, dimensionStyle);
            dim9.UserText = "LCCB = " + Math.Round(lccb / scale, 2);
            dxf.AddEntity(dim9);
            //尺寸10
            LinearDimension dim10 = new LinearDimension(new Line(v4, v6), offset * 2 + (v4.X - v6.X) / 2, 270, dimensionStyle);
            dim10.UserText = "LU = " + Math.Round(lu / scale, 2);
            dxf.AddEntity(dim10);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, v6.Y + 210 + oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void ShellCounterbore(Dictionary<string, Object> data)  //套式锪钻
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 18)
            {
                scale = 15.0;
            }
            else if (scale == 0 && soal < 27)
            {
                scale = 10.0;
            }
            else if (scale == 0 && soal < 54)
            {
                scale = 5.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 135)
            {
                scale = 2.0;
            }
            else if (scale == 0)
            {
                scale = 1.0;
            }
            double df = Convert.ToDouble(data["df"]) * scale;
            double dc = Convert.ToDouble(data["dc"]) * scale;
            double dcintf = Convert.ToDouble(data["dcintf"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double lu = Convert.ToDouble(data["lu"]) * scale;
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            Vector2 v1 = new Vector2(dcintf / 2, 0);
            Vector2 v2 = new Vector2(df / 2, 0);
            Vector2 v3 = new Vector2(v2.X, -oal + lu);
            Vector2 v4 = new Vector2(dc / 2, v3.Y - (dc - df) / 2);
            Vector2 v5 = new Vector2(v4.X, -oal);
            Vector2 v6 = new Vector2(v1.X, -oal);
            Vector2 v7 = new Vector2(-v6.X, v6.Y);
            Vector2 v8 = new Vector2(-v5.X, v5.Y);
            Vector2 v9 = new Vector2(-v4.X, v4.Y);
            Vector2 v10 = new Vector2(-v3.X, v3.Y);
            Vector2 v11 = new Vector2(-v2.X, v2.Y);
            Vector2 v12 = new Vector2(-v1.X, v1.Y);
            Vector2 v13 = new Vector2(0, v10.Y);
            Vector2 v14 = new Vector2(0, v9.Y);
            Vector2 v15 = new Vector2(0, 2);
            Vector2 v16 = new Vector2(0, -oal - 2);
            //线段
            //主视图
            Vector2[] Line1 = { v11, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v8 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v8, v9 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v9, v10 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v10, v11 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v1, v6 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v10, v13 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v9, v14 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v12, v7 };
            fun.drawPlinetype(dxf, Line12, 0.15, refin, Linetype.Dashed);
            Vector2[] Line13 = { v15, v16 };
            fun.drawPlinetype(dxf, Line13, 0.15, centre, Linetype.Center);
            //填充
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v1));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v2));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v3));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v4));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v5));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v6));
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsubofline(dxf, htype1, hnumst1, 45, oal / scale / 2, hline1, hatching);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v7, v6), -offset, 0, dimensionStyle);
            dim2.UserText = "DCINTF = " + Math.Round(dcintf / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            LinearDimension dim3 = new LinearDimension(new Line(v8, v5), -offset * 2, 0, dimensionStyle);
            dim3.UserText = "DC = " + Math.Round(dc / scale, 2);
            dxf.AddEntity(dim3);
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v2, v5), offset * 2 + (v5.X - v2.X) / 2, 270, dimensionStyle);
            dim5.UserText = "OAL.LPR = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸8
            LinearDimension dim8 = new LinearDimension(new Line(v11, v2), offset, 0, dimensionStyle);
            dim8.UserText = "DF = " + Math.Round(df / scale, 2);
            dxf.AddEntity(dim8);
            //尺寸10
            LinearDimension dim10 = new LinearDimension(new Line(v3, v5), offset + (v5.X - v3.X) / 2, 270, dimensionStyle);
            dim10.UserText = "LU = " + Math.Round(lu / scale, 2);
            dxf.AddEntity(dim10);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, v5.Y + 210 + oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void TaperedShellCountersinkingTool(Dictionary<string, Object> data)  //锥形套式锪孔工具
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 18)
            {
                scale = 15.0;
            }
            else if (scale == 0 && soal < 27)
            {
                scale = 10.0;
            }
            else if (scale == 0 && soal < 54)
            {
                scale = 5.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 135)
            {
                scale = 2.0;
            }
            else if (scale == 0)
            {
                scale = 1.0;
            }
            double pi = Math.PI;
            double dc1 = Convert.ToDouble(data["dc1"]) * scale;
            double dc2 = Convert.ToDouble(data["dc2"]) * scale;
            double dcb = Convert.ToDouble(data["dcb"]) * scale;
            double sig = Convert.ToDouble(data["sig"]) * pi / 180;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double isframe = Convert.ToDouble(data["isframe"]);
            double sdl1 = (dc2 - dc1) / 2 / Math.Tan(sig / 2);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            Vector2 v1 = new Vector2(dcb / 2, 0);
            Vector2 v2 = new Vector2(dc2 / 2, 0);
            Vector2 v3 = new Vector2(v2.X, -oal + sdl1);
            Vector2 v4 = new Vector2(dc1 / 2, -oal);
            Vector2 v5 = new Vector2(v1.X, -oal);
            Vector2 v6 = new Vector2(-v5.X, v5.Y);
            Vector2 v7 = new Vector2(-v4.X, v4.Y);
            Vector2 v8 = new Vector2(-v3.X, v3.Y);
            Vector2 v9 = new Vector2(-v2.X, v2.Y);
            Vector2 v10 = new Vector2(-v1.X, v1.Y);
            Vector2 v11 = new Vector2(0, v8.Y);
            Vector2 v12 = new Vector2(0, 2);
            Vector2 v13 = new Vector2(0, -oal - 2);
            Vector2 v14 = new Vector2(0, v4.Y - dc1 / 2 / Math.Tan(sig / 2));
            Vector2 v15 = new Vector2(v7.X, v14.Y * 2 - v7.Y);
            Vector2 v16 = new Vector2(v4.X, v14.Y * 2 - v4.Y);
            //线段
            //主视图
            Vector2[] Line1 = { v9, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v7 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v7, v8 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v8, v9 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v1, v5 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v8, v11 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v10, v6 };
            fun.drawPlinetype(dxf, Line9, 0.15, refin, Linetype.Dashed);
            Vector2[] Line10 = { v12, v13 };
            fun.drawPlinetype(dxf, Line10, 0.15, centre, Linetype.Center);
            Line Line11 = new Line(v4, v15);
            Line Line12 = new Line(v7, v16);
            Line11.Layer = dimensioning;
            Line12.Layer = dimensioning;
            dxf.AddEntity(Line11);
            dxf.AddEntity(Line12);
            //填充
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v1));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v2));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v3));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v4));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v5));
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsubofline(dxf, htype1, hnumst1, 45, oal / scale / 2, hline1, hatching);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            Angular2LineDimension angdim1 = new Angular2LineDimension(Line11, Line12, offset / 2, dimensionStyle);
            angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
            dxf.AddEntity(angdim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v7, v4), v14.Y - v4.Y - offset - 5, 0, dimensionStyle);
            dim2.UserText = "DC_1 = " + Math.Round(dc1 / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            LinearDimension dim3 = new LinearDimension(new Line(v8, v3), v14.Y - v3.Y - offset * 2, 0, dimensionStyle);
            dim3.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
            dxf.AddEntity(dim3);
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v2, v4), offset * 2 + (v2.X - v4.X) / 2, 270, dimensionStyle);
            dim5.UserText = "OAL.LPR = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v10, v1), offset, 0, dimensionStyle);
            dim6.UserText = "DCB = " + Math.Round(dcb / scale, 2);
            dxf.AddEntity(dim6);
            //尺寸10
            LinearDimension dim10 = new LinearDimension(new Line(v3, v4), offset + (v3.X - v4.X) / 2, 270, dimensionStyle);
            dim10.UserText = "SDL_1 = " + Math.Round(sdl1 / scale, 2);
            dxf.AddEntity(dim10);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, v4.Y + 210 + oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void SteppedShellCountersinkingTool(Dictionary<string, Object> data)  //阶梯形套式锪孔工具
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            //作图
            //参数
            double soal = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && soal < 18)
            {
                scale = 15.0;
            }
            else if (scale == 0 && soal < 27)
            {
                scale = 10.0;
            }
            else if (scale == 0 && soal < 54)
            {
                scale = 5.0;
            }
            else if (scale == 0 && soal < 90)
            {
                scale = 3.0;
            }
            else if (scale == 0 && soal < 135)
            {
                scale = 2.0;
            }
            else if (scale == 0)
            {
                scale = 1.0;
            }
            double pi = Math.PI;
            double dc1 = Convert.ToDouble(data["dc1"]) * scale;
            double dc2 = Convert.ToDouble(data["dc2"]) * scale;
            double dcintf = Convert.ToDouble(data["dcintf"]) * scale;
            double sdl1 = Convert.ToDouble(data["sdl1"]) * scale;
            double dcb = Convert.ToDouble(data["dcb"]) * scale;
            double sig = Convert.ToDouble(data["sig"]) * pi / 180;
            double sta2 = Convert.ToDouble(data["sta2"]) * pi / 180;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double isframe = Convert.ToDouble(data["isframe"]);
            double pl = (dc1 - dcintf) / 2 / (Math.Tan(sig / 2));
            double sd2 = (dc1 - dcintf) / 2 / (Math.Tan(sig / 2)) + sdl1 + (dc2 - dc1) / 2 / (Math.Tan(sta2 / 2));
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            Vector2 v1 = new Vector2(dcb / 2, 0);
            Vector2 v2 = new Vector2(dc2 / 2, 0);
            Vector2 v3 = new Vector2(v2.X, -oal + sd2);
            Vector2 v4 = new Vector2(dc1 / 2, -oal + pl + sdl1);
            Vector2 v5 = new Vector2(v4.X, -oal + pl);
            Vector2 v6 = new Vector2(dcintf / 2, -oal);
            Vector2 v7 = new Vector2(v1.X, v6.Y);
            Vector2 v8 = new Vector2(-v7.X, v7.Y);
            Vector2 v9 = new Vector2(-v6.X, v6.Y);
            Vector2 v10 = new Vector2(-v5.X, v5.Y);
            Vector2 v11 = new Vector2(-v4.X, v4.Y);
            Vector2 v12 = new Vector2(-v3.X, v3.Y);
            Vector2 v13 = new Vector2(-v2.X, v2.Y);
            Vector2 v14 = new Vector2(-v1.X, v1.Y);
            Vector2 v15 = new Vector2(0, v3.Y);
            Vector2 v16 = new Vector2(0, v4.Y);
            Vector2 v17 = new Vector2(0, v5.Y);
            Vector2 v18 = new Vector2(0, 2);
            Vector2 v19 = new Vector2(0, -oal - 2);
            Vector2 v20 = new Vector2(0, v6.Y - dcintf / 2 / Math.Tan(sig / 2));
            Vector2 v21 = new Vector2(v9.X, v20.Y * 2 - v9.Y);
            Vector2 v22 = new Vector2(v6.X, v20.Y * 2 - v6.Y);
            //线段
            //主视图
            Vector2[] Line1 = { v13, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v9 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v9, v10 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v10, v11 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v11, v12 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v12, v13 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v1, v7 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v12, v15 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v11, v16 };
            fun.drawBLine(dxf, Line13, 0.3, contour);
            Vector2[] Line14 = { v10, v17 };
            fun.drawBLine(dxf, Line14, 0.3, contour);
            Vector2[] Line15 = { v14, v8 };
            fun.drawPlinetype(dxf, Line15, 0.15, refin, Linetype.Dashed);
            Vector2[] Line16 = { v18, v19 };
            fun.drawPlinetype(dxf, Line16, 0.15, centre, Linetype.Center);
            Line Line17 = new Line(v6, v21);
            Line Line18 = new Line(v9, v22);
            Line17.Layer = dimensioning;
            Line18.Layer = dimensioning;
            dxf.AddEntity(Line17);
            dxf.AddEntity(Line18);
            //填充
            LwPolyline hatchpoly1 = new LwPolyline();
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v1));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v2));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v3));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v4));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v5));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v6));
            hatchpoly1.Vertexes.Add(new LwPolylineVertex(v7));
            hatchpoly1.IsClosed = true;
            String[] htype1 = new String[100];
            Line[] hline1 = new Line[100];
            int hnumst1 = hatchpoly1.Explode().Count;  //记录爆炸后，线段有多少
            for (int i = 0; i < hnumst1; i++)
            {
                htype1[i] = hatchpoly1.Explode()[i].Type.ToString();    //将所有的元素记录成一个数组
                if (htype1[i] == "Line")
                {
                    hline1[i] = (Line)hatchpoly1.Explode()[i];
                }
            }
            fun.hatchsubofline(dxf, htype1, hnumst1, 45, oal / scale / 2, hline1, hatching);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            Angular2LineDimension angdim1 = new Angular2LineDimension(Line17, Line18, offset / 2, dimensionStyle);
            angdim1.UserText = "SIG = " + Math.Round(sig / (pi / 180), 2) + "°";
            dxf.AddEntity(angdim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v9, v6), v20.Y - v6.Y - offset - 5, 0, dimensionStyle);
            dim2.UserText = "DCINTF = " + Math.Round(dcintf / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            LinearDimension dim3 = new LinearDimension(new Line(v14, v1), offset, 0, dimensionStyle);
            dim3.UserText = "DCB = " + Math.Round(dcb / scale, 2);
            dxf.AddEntity(dim3);
            //尺寸11
            LinearDimension dim11 = new LinearDimension(new Line(v10, v5), v20.Y - v5.Y - offset * 2, 0, dimensionStyle);
            dim11.UserText = "DC_1 = " + Math.Round(dc1 / scale, 2);
            dxf.AddEntity(dim11);
            //尺寸12
            LinearDimension dim12 = new LinearDimension(new Line(v13, v2), offset * 2, 0, dimensionStyle);
            dim12.UserText = "DC_2 = " + Math.Round(dc2 / scale, 2);
            dxf.AddEntity(dim12);
            //尺寸4
            LinearDimension dim4 = new LinearDimension(new Line(v5, v6), offset + (v5.X - v6.X) / 2, 270, dimensionStyle);
            dim4.UserText = "PL = " + Math.Round(pl / scale, 2);
            dxf.AddEntity(dim4);
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v2, v6), offset * 3 + (v2.X - v6.X) / 2, 270, dimensionStyle);
            dim5.UserText = "OAL.LPR = " + Math.Round(oal / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸9
            LinearDimension dim9 = new LinearDimension(new Line(v4, v5), offset + v2.X - v4.X, 270, dimensionStyle);
            dim9.UserText = "SDL_1 = " + Math.Round(sdl1 / scale, 2);
            dxf.AddEntity(dim9);
            //尺寸10
            LinearDimension dim10 = new LinearDimension(new Line(v3, v6), offset * 2 + (v3.X - v6.X) / 2, 270, dimensionStyle);
            dim10.UserText = "SD_2 = " + Math.Round(sd2 / scale, 2);
            dxf.AddEntity(dim10);
            //尺寸6
            Angular2LineDimension angdim6 = new Angular2LineDimension(new Line(v11, v12), new Line(v4, v3), offset + dc1 / 2 / Math.Tan(sta2 / 2), dimensionStyle);
            angdim6.UserText = "STA_2 = " + Math.Round(sta2 / (pi / 180), 2) + "°";
            dxf.AddEntity(angdim6);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, v6.Y + 210 + oal / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
        public static void GuidePilots(Dictionary<string, Object> data)  //导柱
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层
            //作图
            //参数
            double sgpl = Convert.ToDouble(data["gpl"]);
            double scale = Convert.ToDouble(data["scale"]); //放大系数
            if (scale == 0 && sgpl < 10)
            {
                scale = 12.5;
            }
            else if (scale == 0 && sgpl < 15)
            {
                scale = 10.0;
            }
            else if (scale == 0 && sgpl < 20)
            {
                scale = 8.0;
            }
            else if (scale == 0 && sgpl < 27)
            {
                scale = 6.0;
            }
            else if (scale == 0 && sgpl < 54)
            {
                scale = 4.0;
            }
            else if (scale == 0)
            {
                scale = 1.0;
            }
            double pi = Math.PI;
            double dcb = Convert.ToDouble(data["dcb"]) * scale;
            double gpd = Convert.ToDouble(data["gpd"]) * scale;
            double gpl = Convert.ToDouble(data["gpl"]) * scale;
            double tl = Convert.ToDouble(data["tl"]) * scale;
            double ta = Convert.ToDouble(data["ta"]) * pi / 180;
            double isframe = Convert.ToDouble(data["isframe"]);
            string path = Convert.ToString(data["path"]);
            //坐标
            //主视图
            Vector2 v1 = new Vector2(dcb / 2, 0);
            Vector2 v2 = new Vector2(v1.X, -gpl / 5);
            Vector2 v3 = new Vector2(gpd / 2, v2.Y);
            Vector2 v4 = new Vector2(v3.X, -gpl + tl);
            Vector2 v5 = new Vector2(v4.X - tl * Math.Tan(ta / 2), -gpl);
            Vector2 v6 = new Vector2(-v5.X, v5.Y);
            Vector2 v7 = new Vector2(-v4.X, v4.Y);
            Vector2 v8 = new Vector2(-v3.X, v3.Y);
            Vector2 v9 = new Vector2(-v2.X, v2.Y);
            Vector2 v10 = new Vector2(-v1.X, v1.Y);
            Vector2 v11 = new Vector2(0, 2);
            Vector2 v12 = new Vector2(0, -gpl - 2);
            Vector2 v13 = new Vector2(0, v5.Y - v5.X / Math.Tan(ta / 2));
            Vector2 v14 = new Vector2(v6.X, 2 * v13.Y - v6.Y);
            Vector2 v15 = new Vector2(v5.X, 2 * v13.Y - v5.Y);
            //线段
            //主视图
            Vector2[] Line1 = { v1, v2 };
            fun.drawBLine(dxf, Line1, 0.3, contour);
            Vector2[] Line2 = { v2, v3 };
            fun.drawBLine(dxf, Line2, 0.3, contour);
            Vector2[] Line3 = { v3, v4 };
            fun.drawBLine(dxf, Line3, 0.3, contour);
            Vector2[] Line4 = { v4, v5 };
            fun.drawBLine(dxf, Line4, 0.3, contour);
            Vector2[] Line5 = { v5, v6 };
            fun.drawBLine(dxf, Line5, 0.3, contour);
            Vector2[] Line6 = { v6, v7 };
            fun.drawBLine(dxf, Line6, 0.3, contour);
            Vector2[] Line7 = { v7, v8 };
            fun.drawBLine(dxf, Line7, 0.3, contour);
            Vector2[] Line8 = { v8, v9 };
            fun.drawBLine(dxf, Line8, 0.3, contour);
            Vector2[] Line9 = { v9, v10 };
            fun.drawBLine(dxf, Line9, 0.3, contour);
            Vector2[] Line10 = { v10, v1 };
            fun.drawBLine(dxf, Line10, 0.3, contour);
            Vector2[] Line11 = { v9, v2 };
            fun.drawBLine(dxf, Line11, 0.3, contour);
            Vector2[] Line12 = { v7, v4 };
            fun.drawBLine(dxf, Line12, 0.3, contour);
            Vector2[] Line13 = { v11, v12 };
            fun.drawPlinetype(dxf, Line13, 0.15, centre, Linetype.Center);
            Line Line14 = new Line(v5, v14);
            Line Line15 = new Line(v6, v15);
            //主视图图层
            Line14.Layer = dimensioning;
            Line15.Layer = dimensioning;
            //主视图
            dxf.AddEntity(Line14);
            dxf.AddEntity(Line15);
            //标注样式
            //箭头样式
            DimensionStyle dimensionStyle = fun.CreateDimStyle();
            dimensionStyle.ArrowSize = 0.2;
            dimensionStyle.DimArrow1 = DimensionArrowhead.Closedfilled;
            dimensionStyle.DimArrow2 = DimensionArrowhead.Closedfilled;
            //文本样式
            dimensionStyle.TextHeight = 1.0;
            double offset = 10;
            //线段尺寸标注
            //尺寸1
            Angular2LineDimension angdim1 = new Angular2LineDimension(Line14, Line15, offset / 2, dimensionStyle);
            angdim1.UserText = "TA = " + Math.Round(ta / (pi / 180), 2) + "°";
            dxf.AddEntity(angdim1);
            //尺寸2
            LinearDimension dim2 = new LinearDimension(new Line(v7, v4), -tl - offset - 5, 0, dimensionStyle);
            dim2.UserText = "GPD = " + Math.Round(gpd / scale, 2);
            dxf.AddEntity(dim2);
            //尺寸3
            LinearDimension dim3 = new LinearDimension(new Line(v4, v5), offset + (v4.X - v5.X) / 2, 270, dimensionStyle);
            dim3.UserText = "TL = " + Math.Round(tl / scale, 2);
            dxf.AddEntity(dim3);
            //尺寸5
            LinearDimension dim5 = new LinearDimension(new Line(v5, v1), offset * 2 + v3.X - (v1.X + v5.X) / 2, 270, dimensionStyle);
            dim5.UserText = "GPL = " + Math.Round(gpl / scale, 2);
            dxf.AddEntity(dim5);
            //尺寸6
            LinearDimension dim6 = new LinearDimension(new Line(v10, v1), offset, 0, dimensionStyle);
            dim6.UserText = "DCB = " + Math.Round(dcb / scale, 2);
            dxf.AddEntity(dim6);
            //图框
            if (isframe == 1)
            {
                Dictionary<string, Vector2> position = Frame.frameA3Y(dxf, new Vector2(-148.5, v5.Y + 210 + gpl / 2));
                fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
            }
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
    }
}